Coverage for manila/policies/share_transfer.py: 100%
13 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright (c) 2022 China Telecom Digital Intelligence.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from oslo_policy import policy
18from manila.policies import base
21BASE_POLICY_NAME = 'share_transfer:%s'
23DEPRECATED_REASON = """
24The transfer API now supports system scope and default roles.
25"""
27deprecated_share_transfer_get_all = policy.DeprecatedRule(
28 name=BASE_POLICY_NAME % 'get_all',
29 check_str=base.RULE_DEFAULT,
30 deprecated_reason=DEPRECATED_REASON,
31 deprecated_since="Antelope"
32)
33deprecated_share_transfer_get_all_tenant = policy.DeprecatedRule(
34 name=BASE_POLICY_NAME % 'get_all_tenant',
35 check_str=base.RULE_ADMIN_API,
36 deprecated_reason=DEPRECATED_REASON,
37 deprecated_since="Antelope"
38)
39deprecated_share_transfer_create = policy.DeprecatedRule(
40 name=BASE_POLICY_NAME % 'create',
41 check_str=base.RULE_DEFAULT,
42 deprecated_reason=DEPRECATED_REASON,
43 deprecated_since="Antelope"
44)
45deprecated_share_transfer_get = policy.DeprecatedRule(
46 name=BASE_POLICY_NAME % 'get',
47 check_str=base.RULE_DEFAULT,
48 deprecated_reason=DEPRECATED_REASON,
49 deprecated_since="Antelope"
50)
51deprecated_share_transfer_accept = policy.DeprecatedRule(
52 name=BASE_POLICY_NAME % 'accept',
53 check_str=base.RULE_DEFAULT,
54 deprecated_reason=DEPRECATED_REASON,
55 deprecated_since="Antelope"
56)
57deprecated_share_transfer_delete = policy.DeprecatedRule(
58 name=BASE_POLICY_NAME % 'delete',
59 check_str=base.RULE_DEFAULT,
60 deprecated_reason=DEPRECATED_REASON,
61 deprecated_since="Antelope"
62)
65share_transfer_policies = [
66 policy.DocumentedRuleDefault(
67 name=BASE_POLICY_NAME % 'get_all',
68 check_str=base.ADMIN_OR_PROJECT_READER,
69 description="List share transfers.",
70 operations=[
71 {
72 'method': 'GET',
73 'path': '/share-transfers'
74 },
75 {
76 'method': 'GET',
77 'path': '/share-transfers/detail'
78 }
79 ],
80 deprecated_rule=deprecated_share_transfer_get_all
81 ),
82 policy.DocumentedRuleDefault(
83 name=BASE_POLICY_NAME % 'get_all_tenant',
84 check_str=base.ADMIN,
85 scope_types=['project'],
86 description="List share transfers with all tenants.",
87 operations=[
88 {
89 'method': 'GET',
90 'path': '/share-transfers'
91 },
92 {
93 'method': 'GET',
94 'path': '/share-transfers/detail'
95 }
96 ],
97 deprecated_rule=deprecated_share_transfer_get_all_tenant
98 ),
99 policy.DocumentedRuleDefault(
100 name=BASE_POLICY_NAME % 'create',
101 check_str=base.ADMIN_OR_PROJECT_MEMBER,
102 description="Create a share transfer.",
103 operations=[
104 {
105 'method': 'POST',
106 'path': '/share-transfers'
107 }
108 ],
109 deprecated_rule=deprecated_share_transfer_create
110 ),
111 policy.DocumentedRuleDefault(
112 name=BASE_POLICY_NAME % 'get',
113 check_str=base.ADMIN_OR_PROJECT_READER,
114 description="Show one specified share transfer.",
115 operations=[
116 {
117 'method': 'GET',
118 'path': '/share-transfers/{transfer_id}'
119 }
120 ],
121 deprecated_rule=deprecated_share_transfer_get
122 ),
123 policy.DocumentedRuleDefault(
124 name=BASE_POLICY_NAME % 'accept',
125 check_str=base.ADMIN_OR_PROJECT_MEMBER,
126 description="Accept a share transfer.",
127 operations=[
128 {
129 'method': 'POST',
130 'path': '/share-transfers/{transfer_id}/accept'
131 }
132 ],
133 deprecated_rule=deprecated_share_transfer_accept
134 ),
135 policy.DocumentedRuleDefault(
136 name=BASE_POLICY_NAME % 'delete',
137 check_str=base.ADMIN_OR_PROJECT_MEMBER,
138 description="Delete share transfer.",
139 operations=[
140 {
141 'method': 'DELETE',
142 'path': '/share-transfers/{transfer_id}'
143 }
144 ],
145 deprecated_rule=deprecated_share_transfer_delete
146 ),
147]
150def list_rules():
151 return share_transfer_policies