Coverage for manila/api/schemas/shares.py: 100%
48 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# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
13import copy
15from manila.api.validation import parameter_types
16from manila.common import constants
19_status = {
20 'type': 'string',
21 'enum': list(constants.SHARE_STATUSES),
22}
24reset_status_request_body = {
25 'type': 'object',
26 'properties': {
27 'os-reset_status': {
28 'type': 'object',
29 'properties': {
30 # TODO(stephenfin): Remove the os-status in a future
31 # microversion and make 'status' required
32 'os-status': _status,
33 'status': _status,
34 },
35 'required': [],
36 # TODO(stephenfin): Set to False in a future microversion
37 'additionalProperties': True,
38 },
39 },
40 'required': ['os-reset_status'],
41 'additionalProperties': False,
42}
44reset_status_request_body_v27 = copy.deepcopy(reset_status_request_body)
45reset_status_request_body_v27['properties']['reset_status'] = (
46 reset_status_request_body_v27['properties'].pop('os-reset_status')
47)
48reset_status_request_body_v27['required'] = ['reset_status']
50force_delete_request_body = {
51 'type': 'object',
52 'properties': {
53 # TODO(stephenfin): We should restrict this to 'null' in a future
54 # microversion
55 'os-force_delete': {},
56 },
57 'required': ['os-force_delete'],
58 'additionalProperties': False,
59}
61force_delete_request_body_v27 = copy.deepcopy(force_delete_request_body)
62force_delete_request_body_v27['properties']['force_delete'] = (
63 force_delete_request_body_v27['properties'].pop('os-force_delete')
64)
65force_delete_request_body_v27['required'] = ['force_delete']
67soft_delete_request_body = {
68 'type': 'object',
69 'properties': {
70 # TODO(stephenfin): We should restrict this to 'null' in a future
71 # microversion
72 'soft_delete': {},
73 },
74 'required': ['soft_delete'],
75 'additionalProperties': False,
76}
78restore_request_body = {
79 'type': 'object',
80 'properties': {
81 # TODO(stephenfin): We should restrict this to 'null' in a future
82 # microversion
83 'restore': {},
84 },
85 'required': ['restore'],
86 'additionalProperties': False,
87}
89migration_start_request_body = {
90 'type': 'object',
91 'properties': {
92 'migration_start': {
93 'type': 'object',
94 'properties': {
95 'force_host_assisted_migration': parameter_types.boolean,
96 # TODO(stephenfin): Add pattern for `host@backend#pool`
97 'host': {'type': 'string'},
98 # TODO(stephenfin): Should we enforce format=uuid here?
99 'new_share_network_id': {'type': ['string', 'null']},
100 'new_share_type_id': {'type': ['string', 'null']},
101 'nondisruptive': parameter_types.boolean,
102 'preserve_metadata': parameter_types.boolean,
103 'preserve_snapshots': parameter_types.boolean,
104 'writable': parameter_types.boolean,
105 },
106 'required': [
107 'host',
108 'nondisruptive',
109 'preserve_metadata',
110 'preserve_snapshots',
111 'writable',
112 ],
113 # TODO(stephenfin): Set to False in a future microversion
114 'additionalProperties': True,
115 },
116 },
117 'required': ['migration_start'],
118 'additionalProperties': False,
119}
122migration_complete_request_body = {
123 'type': 'object',
124 'properties': {
125 # TODO(stephenfin): We should restrict this to 'null' in a future
126 # microversion
127 'migration_complete': {},
128 },
129 'required': ['migration_complete'],
130 'additionalProperties': False,
131}
133migration_cancel_request_body = {
134 'type': 'object',
135 'properties': {
136 # TODO(stephenfin): We should restrict this to 'null' in a future
137 # microversion
138 'migration_cancel': {},
139 },
140 'required': ['migration_cancel'],
141 'additionalProperties': False,
142}
144migration_get_progress_request_body = {
145 'type': 'object',
146 'properties': {
147 # TODO(stephenfin): We should restrict this to 'null' in a future
148 # microversion
149 'migration_get_progress': {},
150 },
151 'required': ['migration_get_progress'],
152 'additionalProperties': False,
153}
155_task_state = {
156 'type': ['string', 'null'],
157 'enum': constants.TASK_STATE_STATUSES,
158}
160reset_task_state_request_body = {
161 'type': 'object',
162 'properties': {
163 'reset_task_state': {
164 'type': 'object',
165 'properties': {
166 # TODO(stephenfin): Remove os-task_state field in a future
167 # microversion and make task_state required
168 'os-task_state': _task_state,
169 'task_state': _task_state,
170 },
171 'required': [],
172 # TODO(stephenfin): Set to False in a future microversion
173 'additionalProperties': True,
174 },
175 },
176 'required': ['reset_task_state'],
177 'additionalProperties': False,
178}
180extend_request_body = {
181 'type': 'object',
182 'properties': {
183 'os-extend': {
184 'type': 'object',
185 'properties': {
186 'new_size': parameter_types.non_negative_integer,
187 },
188 'required': ['new_size'],
189 # TODO(stephenfin): Set to False in a future microversion
190 'additionalProperties': True,
191 }
192 },
193 'required': ['os-extend'],
194 'additionalProperties': False,
195}
197extend_request_body_v27 = copy.deepcopy(extend_request_body)
198extend_request_body_v27['properties']['extend'] = (
199 extend_request_body_v27['properties'].pop('os-extend')
200)
201extend_request_body_v27['required'] = ['extend']
203extend_request_body_v264 = copy.deepcopy(extend_request_body_v27)
204extend_request_body_v264['properties']['extend']['properties'].update({
205 'force': parameter_types.boolean
206})
208shrink_request_body = {
209 'type': 'object',
210 'properties': {
211 'os-shrink': {
212 'type': 'object',
213 'properties': {
214 'new_size': parameter_types.non_negative_integer,
215 },
216 'required': ['new_size'],
217 # TODO(stephenfin): Set to False in a future microversion
218 'additionalProperties': True,
219 }
220 },
221 'required': ['os-shrink'],
222 'additionalProperties': False,
223}
225shrink_request_body_v27 = copy.deepcopy(shrink_request_body)
226shrink_request_body_v27['properties']['shrink'] = (
227 shrink_request_body_v27['properties'].pop('os-shrink')
228)
229shrink_request_body_v27['required'] = ['shrink']
231unmanage_request_body = {
232 'type': 'object',
233 'properties': {
234 # TODO(stephenfin): We should restrict this to 'null' in a future
235 # microversion
236 'unmanage': {},
237 },
238 'required': ['unmanage'],
239 'additionalProperties': False,
240}
242revert_request_body = {
243 'type': 'object',
244 'properties': {
245 # TODO(stephenfin): We should restrict this to 'null' in a future
246 # microversion
247 'revert': {
248 'type': 'object',
249 'properties': {
250 'snapshot_id': {
251 'type': 'string', 'format': 'uuid'
252 },
253 },
254 'required': ['snapshot_id'],
255 # TODO(stephenfin): Set to False in a future microversion
256 'additionalProperties': True,
257 },
258 },
259 'required': ['revert'],
260 'additionalProperties': False,
261}
263reset_status_response_body = {'type': 'null'}
265force_delete_response_body = {'type': 'null'}
267soft_delete_response_body = {'type': 'null'}
269restore_response_body = {'type': 'null'}
271migration_start_response_body = {'type': 'null'}
273migration_complete_response_body = {'type': 'null'}
275migration_cancel_response_body = {'type': 'null'}
277migration_get_progress_response_body = {
278 'type': 'object',
279 'properties': {
280 'task_state': {
282 },
283 'total_progress': {'type': 'integer', 'min': 0, 'max': 100},
284 },
285 'required': ['task_state', 'total_progress'],
286 'additionalProperties': False,
287}
289migration_get_progress_response_body_v259 = copy.deepcopy(
290 migration_get_progress_response_body
291)
292migration_get_progress_response_body_v259['properties'].update({
293 # TODO(stephenfin): What is the type of this?
294 'details': {},
295})
296migration_get_progress_response_body_v259['required'].append('details')
298reset_task_state_response_body = {'type': 'null'}
300extend_response_body = {'type': 'null'}
302shrink_response_body = {'type': 'null'}
304unmanage_response_body = {'type': 'null'}
306revert_response_body = {'type': 'null'}