Skip to content

Commit b190338

Browse files
authored
{Compute} az disk-access: Migrate to Code Gen V2 (#30869)
1 parent 1ae0fd0 commit b190338

File tree

18 files changed

+3175
-1488
lines changed

18 files changed

+3175
-1488
lines changed

src/azure-cli/azure/cli/command_modules/vm/_help.py

-27
Original file line numberDiff line numberDiff line change
@@ -91,33 +91,6 @@
9191
crafted: true
9292
"""
9393

94-
helps['disk-access create'] = """
95-
type: command
96-
short-summary: Create a disk access resource.
97-
examples:
98-
- name: Create a disk access resource.
99-
text: >
100-
az disk-access create -g MyResourceGroup -l centraluseuap -n MyDiskAccess
101-
"""
102-
103-
helps['disk-access update'] = """
104-
type: command
105-
short-summary: Update a disk access resource.
106-
examples:
107-
- name: Update a disk access resource.
108-
text: >
109-
az disk-access update -g MyResourceGroup -n MyDiskAccess --tags tag1=val1 tag2=val2
110-
"""
111-
112-
helps['disk-access wait'] = """
113-
type: command
114-
short-summary: Place the CLI in a waiting state until a condition of a disk access is met.
115-
examples:
116-
- name: Place the CLI in a waiting state until the disk access is created with 'provisioningState' at 'Succeeded'.
117-
text: |
118-
az disk-access wait --created -g MyResourceGroup -n MyDiskAccess
119-
"""
120-
12194
helps['disk-encryption-set create'] = """
12295
type: command
12396
short-summary: Create a disk encryption set.

src/azure-cli/azure/cli/command_modules/vm/_params.py

-7
Original file line numberDiff line numberDiff line change
@@ -1510,13 +1510,6 @@ def load_arguments(self, _):
15101510
'Check out help for more examples')
15111511
# endregion
15121512

1513-
# region DiskAccess
1514-
with self.argument_context('disk-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disk_accesses') as c:
1515-
c.argument('disk_access_name', arg_type=name_arg_type, help='Name of the disk access resource.', id_part='name')
1516-
c.argument('location', validator=get_default_location_from_resource_group)
1517-
c.argument('tags', tags_type)
1518-
# endRegion
1519-
15201513
# region Capacity
15211514
with self.argument_context('capacity reservation group') as c:
15221515
c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/disk_access/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
# flake8: noqa
1010

1111
from .__cmd_group import *
12+
from ._create import *
1213
from ._delete import *
1314
from ._list import *
1415
from ._show import *
16+
from ._update import *
1517
from ._wait import *
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"disk-access create",
16+
)
17+
class Create(AAZCommand):
18+
"""Create a disk access resource
19+
20+
:example: Create a disk access resource.
21+
az disk-access create -g MyResourceGroup -l centraluseuap -n MyDiskAccess
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2020-05-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/diskaccesses/{}", "2020-05-01"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_NO_WAIT = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_lro_poller(self._execute_operations, self._output)
36+
37+
_args_schema = None
38+
39+
@classmethod
40+
def _build_arguments_schema(cls, *args, **kwargs):
41+
if cls._args_schema is not None:
42+
return cls._args_schema
43+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
44+
45+
# define Arg Group ""
46+
47+
_args_schema = cls._args_schema
48+
_args_schema.disk_access_name = AAZStrArg(
49+
options=["-n", "--name", "--disk-access-name"],
50+
help="The name of the disk access resource that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.",
51+
required=True,
52+
)
53+
_args_schema.resource_group = AAZResourceGroupNameArg(
54+
required=True,
55+
)
56+
57+
# define Arg Group "DiskAccess"
58+
59+
_args_schema = cls._args_schema
60+
_args_schema.location = AAZResourceLocationArg(
61+
arg_group="DiskAccess",
62+
help="Resource location",
63+
required=True,
64+
fmt=AAZResourceLocationArgFormat(
65+
resource_group_arg="resource_group",
66+
),
67+
)
68+
_args_schema.tags = AAZDictArg(
69+
options=["--tags"],
70+
arg_group="DiskAccess",
71+
help="Resource tags",
72+
)
73+
74+
tags = cls._args_schema.tags
75+
tags.Element = AAZStrArg()
76+
return cls._args_schema
77+
78+
def _execute_operations(self):
79+
self.pre_operations()
80+
yield self.DiskAccessesCreateOrUpdate(ctx=self.ctx)()
81+
self.post_operations()
82+
83+
@register_callback
84+
def pre_operations(self):
85+
pass
86+
87+
@register_callback
88+
def post_operations(self):
89+
pass
90+
91+
def _output(self, *args, **kwargs):
92+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
93+
return result
94+
95+
class DiskAccessesCreateOrUpdate(AAZHttpOperation):
96+
CLIENT_TYPE = "MgmtClient"
97+
98+
def __call__(self, *args, **kwargs):
99+
request = self.make_request()
100+
session = self.client.send_request(request=request, stream=False, **kwargs)
101+
if session.http_response.status_code in [202]:
102+
return self.client.build_lro_polling(
103+
self.ctx.args.no_wait,
104+
session,
105+
self.on_200,
106+
self.on_error,
107+
lro_options={"final-state-via": "azure-async-operation"},
108+
path_format_arguments=self.url_parameters,
109+
)
110+
if session.http_response.status_code in [200]:
111+
return self.client.build_lro_polling(
112+
self.ctx.args.no_wait,
113+
session,
114+
self.on_200,
115+
self.on_error,
116+
lro_options={"final-state-via": "azure-async-operation"},
117+
path_format_arguments=self.url_parameters,
118+
)
119+
120+
return self.on_error(session.http_response)
121+
122+
@property
123+
def url(self):
124+
return self.client.format_url(
125+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}",
126+
**self.url_parameters
127+
)
128+
129+
@property
130+
def method(self):
131+
return "PUT"
132+
133+
@property
134+
def error_format(self):
135+
return "ODataV4Format"
136+
137+
@property
138+
def url_parameters(self):
139+
parameters = {
140+
**self.serialize_url_param(
141+
"diskAccessName", self.ctx.args.disk_access_name,
142+
required=True,
143+
),
144+
**self.serialize_url_param(
145+
"resourceGroupName", self.ctx.args.resource_group,
146+
required=True,
147+
),
148+
**self.serialize_url_param(
149+
"subscriptionId", self.ctx.subscription_id,
150+
required=True,
151+
),
152+
}
153+
return parameters
154+
155+
@property
156+
def query_parameters(self):
157+
parameters = {
158+
**self.serialize_query_param(
159+
"api-version", "2020-05-01",
160+
required=True,
161+
),
162+
}
163+
return parameters
164+
165+
@property
166+
def header_parameters(self):
167+
parameters = {
168+
**self.serialize_header_param(
169+
"Content-Type", "application/json",
170+
),
171+
**self.serialize_header_param(
172+
"Accept", "application/json",
173+
),
174+
}
175+
return parameters
176+
177+
@property
178+
def content(self):
179+
_content_value, _builder = self.new_content_builder(
180+
self.ctx.args,
181+
typ=AAZObjectType,
182+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
183+
)
184+
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
185+
_builder.set_prop("tags", AAZDictType, ".tags")
186+
187+
tags = _builder.get(".tags")
188+
if tags is not None:
189+
tags.set_elements(AAZStrType, ".")
190+
191+
return self.serialize_content(_content_value)
192+
193+
def on_200(self, session):
194+
data = self.deserialize_http_content(session)
195+
self.ctx.set_var(
196+
"instance",
197+
data,
198+
schema_builder=self._build_schema_on_200
199+
)
200+
201+
_schema_on_200 = None
202+
203+
@classmethod
204+
def _build_schema_on_200(cls):
205+
if cls._schema_on_200 is not None:
206+
return cls._schema_on_200
207+
208+
cls._schema_on_200 = AAZObjectType()
209+
_CreateHelper._build_schema_disk_access_read(cls._schema_on_200)
210+
211+
return cls._schema_on_200
212+
213+
214+
class _CreateHelper:
215+
"""Helper class for Create"""
216+
217+
_schema_disk_access_read = None
218+
219+
@classmethod
220+
def _build_schema_disk_access_read(cls, _schema):
221+
if cls._schema_disk_access_read is not None:
222+
_schema.id = cls._schema_disk_access_read.id
223+
_schema.location = cls._schema_disk_access_read.location
224+
_schema.name = cls._schema_disk_access_read.name
225+
_schema.properties = cls._schema_disk_access_read.properties
226+
_schema.tags = cls._schema_disk_access_read.tags
227+
_schema.type = cls._schema_disk_access_read.type
228+
return
229+
230+
cls._schema_disk_access_read = _schema_disk_access_read = AAZObjectType()
231+
232+
disk_access_read = _schema_disk_access_read
233+
disk_access_read.id = AAZStrType(
234+
flags={"read_only": True},
235+
)
236+
disk_access_read.location = AAZStrType(
237+
flags={"required": True},
238+
)
239+
disk_access_read.name = AAZStrType(
240+
flags={"read_only": True},
241+
)
242+
disk_access_read.properties = AAZObjectType(
243+
flags={"client_flatten": True},
244+
)
245+
disk_access_read.tags = AAZDictType()
246+
disk_access_read.type = AAZStrType(
247+
flags={"read_only": True},
248+
)
249+
250+
properties = _schema_disk_access_read.properties
251+
properties.private_endpoint_connections = AAZListType(
252+
serialized_name="privateEndpointConnections",
253+
flags={"read_only": True},
254+
)
255+
properties.provisioning_state = AAZStrType(
256+
serialized_name="provisioningState",
257+
flags={"read_only": True},
258+
)
259+
properties.time_created = AAZStrType(
260+
serialized_name="timeCreated",
261+
flags={"read_only": True},
262+
)
263+
264+
private_endpoint_connections = _schema_disk_access_read.properties.private_endpoint_connections
265+
private_endpoint_connections.Element = AAZObjectType()
266+
267+
_element = _schema_disk_access_read.properties.private_endpoint_connections.Element
268+
_element.id = AAZStrType(
269+
flags={"read_only": True},
270+
)
271+
_element.name = AAZStrType(
272+
flags={"read_only": True},
273+
)
274+
_element.properties = AAZObjectType(
275+
flags={"client_flatten": True},
276+
)
277+
_element.type = AAZStrType(
278+
flags={"read_only": True},
279+
)
280+
281+
properties = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties
282+
properties.private_endpoint = AAZObjectType(
283+
serialized_name="privateEndpoint",
284+
)
285+
properties.private_link_service_connection_state = AAZObjectType(
286+
serialized_name="privateLinkServiceConnectionState",
287+
flags={"required": True},
288+
)
289+
properties.provisioning_state = AAZStrType(
290+
serialized_name="provisioningState",
291+
flags={"read_only": True},
292+
)
293+
294+
private_endpoint = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties.private_endpoint
295+
private_endpoint.id = AAZStrType(
296+
flags={"read_only": True},
297+
)
298+
299+
private_link_service_connection_state = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state
300+
private_link_service_connection_state.actions_required = AAZStrType(
301+
serialized_name="actionsRequired",
302+
)
303+
private_link_service_connection_state.description = AAZStrType()
304+
private_link_service_connection_state.status = AAZStrType()
305+
306+
tags = _schema_disk_access_read.tags
307+
tags.Element = AAZStrType()
308+
309+
_schema.id = cls._schema_disk_access_read.id
310+
_schema.location = cls._schema_disk_access_read.location
311+
_schema.name = cls._schema_disk_access_read.name
312+
_schema.properties = cls._schema_disk_access_read.properties
313+
_schema.tags = cls._schema_disk_access_read.tags
314+
_schema.type = cls._schema_disk_access_read.type
315+
316+
317+
__all__ = ["Create"]

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/disk_access/_list.py

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class List(AAZCommand):
2929
]
3030
}
3131

32+
AZ_SUPPORT_PAGINATION = True
33+
3234
def _handler(self, command_args):
3335
super()._handler(command_args)
3436
return self.build_paging(self._execute_operations, self._output)

0 commit comments

Comments
 (0)