|
| 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