Skip to content

Commit d54a4d8

Browse files
authored
{Compute} az vmss get-instance-view: Migrate to aaz-based implementation (#32483)
1 parent 58844de commit d54a4d8

File tree

11 files changed

+7292
-5427
lines changed

11 files changed

+7292
-5427
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
class __CMDGroup(AAZCommandGroup):
15+
"""Manage Instance View
16+
"""
17+
pass
18+
19+
20+
__all__ = ["__CMDGroup"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 .__cmd_group import *
12+
from ._show import *
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
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+
class Show(AAZCommand):
15+
"""Get the status of a VM scale set instance.
16+
"""
17+
18+
_aaz_info = {
19+
"version": "2024-11-01",
20+
"resources": [
21+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/virtualmachinescalesets/{}/instanceview", "2024-11-01"],
22+
]
23+
}
24+
25+
def _handler(self, command_args):
26+
super()._handler(command_args)
27+
self._execute_operations()
28+
return self._output()
29+
30+
_args_schema = None
31+
32+
@classmethod
33+
def _build_arguments_schema(cls, *args, **kwargs):
34+
if cls._args_schema is not None:
35+
return cls._args_schema
36+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
37+
38+
# define Arg Group ""
39+
40+
_args_schema = cls._args_schema
41+
_args_schema.resource_group = AAZResourceGroupNameArg(
42+
required=True,
43+
)
44+
_args_schema.vm_scale_set_name = AAZStrArg(
45+
options=["--vm-scale-set-name"],
46+
help="The name of the VM scale set.",
47+
required=True,
48+
id_part="name",
49+
)
50+
return cls._args_schema
51+
52+
def _execute_operations(self):
53+
self.pre_operations()
54+
self.VirtualMachineScaleSetsGetInstanceView(ctx=self.ctx)()
55+
self.post_operations()
56+
57+
@register_callback
58+
def pre_operations(self):
59+
pass
60+
61+
@register_callback
62+
def post_operations(self):
63+
pass
64+
65+
def _output(self, *args, **kwargs):
66+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
67+
return result
68+
69+
class VirtualMachineScaleSetsGetInstanceView(AAZHttpOperation):
70+
CLIENT_TYPE = "MgmtClient"
71+
72+
def __call__(self, *args, **kwargs):
73+
request = self.make_request()
74+
session = self.client.send_request(request=request, stream=False, **kwargs)
75+
if session.http_response.status_code in [200]:
76+
return self.on_200(session)
77+
78+
return self.on_error(session.http_response)
79+
80+
@property
81+
def url(self):
82+
return self.client.format_url(
83+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView",
84+
**self.url_parameters
85+
)
86+
87+
@property
88+
def method(self):
89+
return "GET"
90+
91+
@property
92+
def error_format(self):
93+
return "ODataV4Format"
94+
95+
@property
96+
def url_parameters(self):
97+
parameters = {
98+
**self.serialize_url_param(
99+
"resourceGroupName", self.ctx.args.resource_group,
100+
required=True,
101+
),
102+
**self.serialize_url_param(
103+
"subscriptionId", self.ctx.subscription_id,
104+
required=True,
105+
),
106+
**self.serialize_url_param(
107+
"vmScaleSetName", self.ctx.args.vm_scale_set_name,
108+
required=True,
109+
),
110+
}
111+
return parameters
112+
113+
@property
114+
def query_parameters(self):
115+
parameters = {
116+
**self.serialize_query_param(
117+
"api-version", "2024-11-01",
118+
required=True,
119+
),
120+
}
121+
return parameters
122+
123+
@property
124+
def header_parameters(self):
125+
parameters = {
126+
**self.serialize_header_param(
127+
"Accept", "application/json",
128+
),
129+
}
130+
return parameters
131+
132+
def on_200(self, session):
133+
data = self.deserialize_http_content(session)
134+
self.ctx.set_var(
135+
"instance",
136+
data,
137+
schema_builder=self._build_schema_on_200
138+
)
139+
140+
_schema_on_200 = None
141+
142+
@classmethod
143+
def _build_schema_on_200(cls):
144+
if cls._schema_on_200 is not None:
145+
return cls._schema_on_200
146+
147+
cls._schema_on_200 = AAZObjectType()
148+
149+
_schema_on_200 = cls._schema_on_200
150+
_schema_on_200.extensions = AAZListType(
151+
flags={"read_only": True},
152+
)
153+
_schema_on_200.orchestration_services = AAZListType(
154+
serialized_name="orchestrationServices",
155+
flags={"read_only": True},
156+
)
157+
_schema_on_200.statuses = AAZListType()
158+
_schema_on_200.virtual_machine = AAZObjectType(
159+
serialized_name="virtualMachine",
160+
flags={"read_only": True},
161+
)
162+
163+
extensions = cls._schema_on_200.extensions
164+
extensions.Element = AAZObjectType()
165+
166+
_element = cls._schema_on_200.extensions.Element
167+
_element.name = AAZStrType(
168+
flags={"read_only": True},
169+
)
170+
_element.statuses_summary = AAZListType(
171+
serialized_name="statusesSummary",
172+
flags={"read_only": True},
173+
)
174+
175+
statuses_summary = cls._schema_on_200.extensions.Element.statuses_summary
176+
statuses_summary.Element = AAZObjectType()
177+
_ShowHelper._build_schema_virtual_machine_status_code_count_read(statuses_summary.Element)
178+
179+
orchestration_services = cls._schema_on_200.orchestration_services
180+
orchestration_services.Element = AAZObjectType()
181+
182+
_element = cls._schema_on_200.orchestration_services.Element
183+
_element.service_name = AAZStrType(
184+
serialized_name="serviceName",
185+
flags={"read_only": True},
186+
)
187+
_element.service_state = AAZStrType(
188+
serialized_name="serviceState",
189+
flags={"read_only": True},
190+
)
191+
192+
statuses = cls._schema_on_200.statuses
193+
statuses.Element = AAZObjectType()
194+
195+
_element = cls._schema_on_200.statuses.Element
196+
_element.code = AAZStrType()
197+
_element.display_status = AAZStrType(
198+
serialized_name="displayStatus",
199+
)
200+
_element.level = AAZStrType()
201+
_element.message = AAZStrType()
202+
_element.time = AAZStrType()
203+
204+
virtual_machine = cls._schema_on_200.virtual_machine
205+
virtual_machine.statuses_summary = AAZListType(
206+
serialized_name="statusesSummary",
207+
flags={"read_only": True},
208+
)
209+
210+
statuses_summary = cls._schema_on_200.virtual_machine.statuses_summary
211+
statuses_summary.Element = AAZObjectType()
212+
_ShowHelper._build_schema_virtual_machine_status_code_count_read(statuses_summary.Element)
213+
214+
return cls._schema_on_200
215+
216+
217+
class _ShowHelper:
218+
"""Helper class for Show"""
219+
220+
_schema_virtual_machine_status_code_count_read = None
221+
222+
@classmethod
223+
def _build_schema_virtual_machine_status_code_count_read(cls, _schema):
224+
if cls._schema_virtual_machine_status_code_count_read is not None:
225+
_schema.code = cls._schema_virtual_machine_status_code_count_read.code
226+
_schema.count = cls._schema_virtual_machine_status_code_count_read.count
227+
return
228+
229+
cls._schema_virtual_machine_status_code_count_read = _schema_virtual_machine_status_code_count_read = AAZObjectType()
230+
231+
virtual_machine_status_code_count_read = _schema_virtual_machine_status_code_count_read
232+
virtual_machine_status_code_count_read.code = AAZStrType(
233+
flags={"read_only": True},
234+
)
235+
virtual_machine_status_code_count_read.count = AAZIntType(
236+
flags={"read_only": True},
237+
)
238+
239+
_schema.code = cls._schema_virtual_machine_status_code_count_read.code
240+
_schema.count = cls._schema_virtual_machine_status_code_count_read.count
241+
242+
243+
__all__ = ["Show"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
class __CMDGroup(AAZCommandGroup):
15+
"""Manage Instance View
16+
"""
17+
pass
18+
19+
20+
__all__ = ["__CMDGroup"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 .__cmd_group import *
12+
from ._show import *

0 commit comments

Comments
 (0)