Skip to content

Commit 05ff94d

Browse files
committed
gallery-appplication crud & livetest
1 parent 5169006 commit 05ff94d

File tree

14 files changed

+1027
-317
lines changed

14 files changed

+1027
-317
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ def cf_gallery_image_versions(cli_ctx, _):
9595
return _compute_client_factory(cli_ctx).gallery_image_versions
9696

9797

98-
def cf_gallery_application(cli_ctx, *_):
99-
return _compute_client_factory(cli_ctx).gallery_applications
100-
101-
10298
def cf_gallery_application_version(cli_ctx, *_):
10399
return _compute_client_factory(cli_ctx).gallery_application_versions
104100

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,29 +1110,6 @@
11101110
short-summary: Manage gallery sharing profile
11111111
"""
11121112

1113-
helps['sig gallery-application'] = """
1114-
type: group
1115-
short-summary: Manage gallery application
1116-
"""
1117-
1118-
helps['sig gallery-application create'] = """
1119-
type: command
1120-
short-summary: "Create a gallery Application Definition."
1121-
examples:
1122-
- name: Create a simple gallery Application.
1123-
text: |-
1124-
az sig gallery-application create --gallery-name MyGallery --name AppName -g MyResourceGroup --os-type windows
1125-
"""
1126-
1127-
helps['sig gallery-application update'] = """
1128-
type: command
1129-
short-summary: "Update a gallery Application Definition."
1130-
examples:
1131-
- name: Update a simple gallery Application.
1132-
text: |-
1133-
az sig gallery-application update --gallery-name GalleryName --name AppName -g MyResourceGroup --description Description --tags tag=MyTag
1134-
"""
1135-
11361113
helps['sig gallery-application wait'] = """
11371114
type: command
11381115
short-summary: Place the CLI in a waiting state until a condition of the sig gallery-application is met.

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,25 +1404,6 @@ def load_arguments(self, _):
14041404
# endregion
14051405

14061406
# region Gallery applications
1407-
with self.argument_context('sig gallery-application') as c:
1408-
c.argument('gallery_application_name', options_list=['--name', '-n', '--application-name'],
1409-
help='The name of the gallery Application')
1410-
1411-
with self.argument_context('sig gallery-application create') as c:
1412-
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
1413-
validator=get_default_location_from_resource_group)
1414-
c.argument('description', help='The description of this gallery Application Definition resource. '
1415-
'This property is updatable.')
1416-
c.argument('os_type', arg_type=get_enum_type(['Windows', 'Linux']), help='This property allows you '
1417-
'to specify the supported type of the OS that application is built for. <br><br> Possible values '
1418-
'are: <br><br> **Windows** <br><br> **Linux**')
1419-
1420-
with self.argument_context('sig gallery-application update') as c:
1421-
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
1422-
validator=get_default_location_from_resource_group)
1423-
c.argument('description', help='The description of this gallery Application Definition resource. '
1424-
'This property is updatable.')
1425-
14261407
with self.argument_context('sig gallery-application version') as c:
14271408
c.argument('gallery_application_name', options_list=['--application-name'],
14281409
help='The name of the gallery Application')

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
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 *
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
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+
"sig gallery-application create",
16+
)
17+
class Create(AAZCommand):
18+
"""Create a gallery Application Definition.
19+
20+
:example: Create a simple gallery Application.
21+
az sig gallery-application create --gallery-name MyGallery --name AppName -g MyResourceGroup --os-type windows
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2021-07-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/galleries/{}/applications/{}", "2021-07-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.application_name = AAZStrArg(
49+
options=["-n", "--name", "--application-name"],
50+
help="The name of the gallery application.",
51+
required=True,
52+
)
53+
_args_schema.gallery_name = AAZStrArg(
54+
options=["-r", "--gallery-name"],
55+
help="Gallery name.",
56+
required=True,
57+
)
58+
_args_schema.resource_group = AAZResourceGroupNameArg(
59+
required=True,
60+
)
61+
_args_schema.location = AAZResourceLocationArg(
62+
help="Resource location",
63+
required=True,
64+
fmt=AAZResourceLocationArgFormat(
65+
resource_group_arg="resource_group",
66+
),
67+
)
68+
_args_schema.description = AAZStrArg(
69+
options=["--description"],
70+
help="The description of this gallery Application Definition resource. This property is updatable.",
71+
)
72+
_args_schema.os_type = AAZStrArg(
73+
options=["--os-type"],
74+
help="This property allows you to specify the supported type of the OS that application is built for. <br><br> Possible values are: <br><br> **Windows** <br><br> **Linux**",
75+
enum={"Linux": "Linux", "Windows": "Windows"},
76+
)
77+
_args_schema.tags = AAZDictArg(
78+
options=["--tags"],
79+
help="Resource tags",
80+
)
81+
82+
tags = cls._args_schema.tags
83+
tags.Element = AAZStrArg()
84+
85+
# define Arg Group "Properties"
86+
return cls._args_schema
87+
88+
def _execute_operations(self):
89+
self.pre_operations()
90+
yield self.GalleryApplicationsCreateOrUpdate(ctx=self.ctx)()
91+
self.post_operations()
92+
93+
@register_callback
94+
def pre_operations(self):
95+
pass
96+
97+
@register_callback
98+
def post_operations(self):
99+
pass
100+
101+
def _output(self, *args, **kwargs):
102+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
103+
return result
104+
105+
class GalleryApplicationsCreateOrUpdate(AAZHttpOperation):
106+
CLIENT_TYPE = "MgmtClient"
107+
108+
def __call__(self, *args, **kwargs):
109+
request = self.make_request()
110+
session = self.client.send_request(request=request, stream=False, **kwargs)
111+
if session.http_response.status_code in [202]:
112+
return self.client.build_lro_polling(
113+
self.ctx.args.no_wait,
114+
session,
115+
self.on_200_201,
116+
self.on_error,
117+
lro_options={"final-state-via": "azure-async-operation"},
118+
path_format_arguments=self.url_parameters,
119+
)
120+
if session.http_response.status_code in [200, 201]:
121+
return self.client.build_lro_polling(
122+
self.ctx.args.no_wait,
123+
session,
124+
self.on_200_201,
125+
self.on_error,
126+
lro_options={"final-state-via": "azure-async-operation"},
127+
path_format_arguments=self.url_parameters,
128+
)
129+
130+
return self.on_error(session.http_response)
131+
132+
@property
133+
def url(self):
134+
return self.client.format_url(
135+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
136+
**self.url_parameters
137+
)
138+
139+
@property
140+
def method(self):
141+
return "PUT"
142+
143+
@property
144+
def error_format(self):
145+
return "ODataV4Format"
146+
147+
@property
148+
def url_parameters(self):
149+
parameters = {
150+
**self.serialize_url_param(
151+
"galleryApplicationName", self.ctx.args.application_name,
152+
required=True,
153+
),
154+
**self.serialize_url_param(
155+
"galleryName", self.ctx.args.gallery_name,
156+
required=True,
157+
),
158+
**self.serialize_url_param(
159+
"resourceGroupName", self.ctx.args.resource_group,
160+
required=True,
161+
),
162+
**self.serialize_url_param(
163+
"subscriptionId", self.ctx.subscription_id,
164+
required=True,
165+
),
166+
}
167+
return parameters
168+
169+
@property
170+
def query_parameters(self):
171+
parameters = {
172+
**self.serialize_query_param(
173+
"api-version", "2021-07-01",
174+
required=True,
175+
),
176+
}
177+
return parameters
178+
179+
@property
180+
def header_parameters(self):
181+
parameters = {
182+
**self.serialize_header_param(
183+
"Content-Type", "application/json",
184+
),
185+
**self.serialize_header_param(
186+
"Accept", "application/json",
187+
),
188+
}
189+
return parameters
190+
191+
@property
192+
def content(self):
193+
_content_value, _builder = self.new_content_builder(
194+
self.ctx.args,
195+
typ=AAZObjectType,
196+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
197+
)
198+
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
199+
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
200+
_builder.set_prop("tags", AAZDictType, ".tags")
201+
202+
properties = _builder.get(".properties")
203+
if properties is not None:
204+
properties.set_prop("description", AAZStrType, ".description")
205+
properties.set_prop("supportedOSType", AAZStrType, ".os_type", typ_kwargs={"flags": {"required": True}})
206+
207+
tags = _builder.get(".tags")
208+
if tags is not None:
209+
tags.set_elements(AAZStrType, ".")
210+
211+
return self.serialize_content(_content_value)
212+
213+
def on_200_201(self, session):
214+
data = self.deserialize_http_content(session)
215+
self.ctx.set_var(
216+
"instance",
217+
data,
218+
schema_builder=self._build_schema_on_200_201
219+
)
220+
221+
_schema_on_200_201 = None
222+
223+
@classmethod
224+
def _build_schema_on_200_201(cls):
225+
if cls._schema_on_200_201 is not None:
226+
return cls._schema_on_200_201
227+
228+
cls._schema_on_200_201 = AAZObjectType()
229+
_CreateHelper._build_schema_gallery_application_read(cls._schema_on_200_201)
230+
231+
return cls._schema_on_200_201
232+
233+
234+
class _CreateHelper:
235+
"""Helper class for Create"""
236+
237+
_schema_gallery_application_read = None
238+
239+
@classmethod
240+
def _build_schema_gallery_application_read(cls, _schema):
241+
if cls._schema_gallery_application_read is not None:
242+
_schema.id = cls._schema_gallery_application_read.id
243+
_schema.location = cls._schema_gallery_application_read.location
244+
_schema.name = cls._schema_gallery_application_read.name
245+
_schema.properties = cls._schema_gallery_application_read.properties
246+
_schema.tags = cls._schema_gallery_application_read.tags
247+
_schema.type = cls._schema_gallery_application_read.type
248+
return
249+
250+
cls._schema_gallery_application_read = _schema_gallery_application_read = AAZObjectType()
251+
252+
gallery_application_read = _schema_gallery_application_read
253+
gallery_application_read.id = AAZStrType(
254+
flags={"read_only": True},
255+
)
256+
gallery_application_read.location = AAZStrType(
257+
flags={"required": True},
258+
)
259+
gallery_application_read.name = AAZStrType(
260+
flags={"read_only": True},
261+
)
262+
gallery_application_read.properties = AAZObjectType(
263+
flags={"client_flatten": True},
264+
)
265+
gallery_application_read.tags = AAZDictType()
266+
gallery_application_read.type = AAZStrType(
267+
flags={"read_only": True},
268+
)
269+
270+
properties = _schema_gallery_application_read.properties
271+
properties.description = AAZStrType()
272+
properties.end_of_life_date = AAZStrType(
273+
serialized_name="endOfLifeDate",
274+
)
275+
properties.eula = AAZStrType()
276+
properties.privacy_statement_uri = AAZStrType(
277+
serialized_name="privacyStatementUri",
278+
)
279+
properties.release_note_uri = AAZStrType(
280+
serialized_name="releaseNoteUri",
281+
)
282+
properties.supported_os_type = AAZStrType(
283+
serialized_name="supportedOSType",
284+
flags={"required": True},
285+
)
286+
287+
tags = _schema_gallery_application_read.tags
288+
tags.Element = AAZStrType()
289+
290+
_schema.id = cls._schema_gallery_application_read.id
291+
_schema.location = cls._schema_gallery_application_read.location
292+
_schema.name = cls._schema_gallery_application_read.name
293+
_schema.properties = cls._schema_gallery_application_read.properties
294+
_schema.tags = cls._schema_gallery_application_read.tags
295+
_schema.type = cls._schema_gallery_application_read.type
296+
297+
298+
__all__ = ["Create"]

0 commit comments

Comments
 (0)