|
| 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 in-vm-access-control-profile create", |
| 16 | +) |
| 17 | +class Create(AAZCommand): |
| 18 | + """Create a gallery in VM access control profile. |
| 19 | +
|
| 20 | + :example: Create a gallery in VM access control profile. |
| 21 | + az sig in-vm-access-control-profile create --resource-group myResourceGroup --gallery-name myGalleryName --name myInVMAccessControlProfileName --location WestUS --os-type Linux --applicable-host-endpoint WireServer |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2024-03-03", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/galleries/{}/invmaccesscontrolprofiles/{}", "2024-03-03"], |
| 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.gallery_name = AAZStrArg( |
| 49 | + options=["--gallery-name"], |
| 50 | + help="The name of the Shared Image Gallery in which the in VM access control profile is to be created.", |
| 51 | + required=True, |
| 52 | + fmt=AAZStrArgFormat( |
| 53 | + pattern="^[a-zA-Z0-9]+([_]?[a-zA-Z0-9]+)*$", |
| 54 | + ), |
| 55 | + ) |
| 56 | + _args_schema.name = AAZStrArg( |
| 57 | + options=["-n", "--name"], |
| 58 | + help="The name of the gallery in VM access control profile to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters.", |
| 59 | + required=True, |
| 60 | + fmt=AAZStrArgFormat( |
| 61 | + pattern="^[a-zA-Z0-9]+([-._]?[a-zA-Z0-9]+)*$", |
| 62 | + max_length=80, |
| 63 | + ), |
| 64 | + ) |
| 65 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 66 | + required=True, |
| 67 | + ) |
| 68 | + |
| 69 | + # define Arg Group "GalleryInVMAccessControlProfile" |
| 70 | + |
| 71 | + _args_schema = cls._args_schema |
| 72 | + _args_schema.location = AAZResourceLocationArg( |
| 73 | + arg_group="GalleryInVMAccessControlProfile", |
| 74 | + help="Resource location", |
| 75 | + required=True, |
| 76 | + fmt=AAZResourceLocationArgFormat( |
| 77 | + resource_group_arg="resource_group", |
| 78 | + ), |
| 79 | + ) |
| 80 | + |
| 81 | + # define Arg Group "Properties" |
| 82 | + |
| 83 | + _args_schema = cls._args_schema |
| 84 | + _args_schema.applicable_host_endpoint = AAZStrArg( |
| 85 | + options=["--applicable-host-endpoint"], |
| 86 | + arg_group="Properties", |
| 87 | + help="This property allows you to specify the Endpoint type for which this profile is defining the access control for. Possible values are: 'WireServer' or 'IMDS'", |
| 88 | + enum={"IMDS": "IMDS", "WireServer": "WireServer"}, |
| 89 | + ) |
| 90 | + _args_schema.description = AAZStrArg( |
| 91 | + options=["--description"], |
| 92 | + arg_group="Properties", |
| 93 | + help="The description of this gallery in VM access control profile resources. This property is updatable.", |
| 94 | + ) |
| 95 | + _args_schema.os_type = AAZStrArg( |
| 96 | + options=["--os-type"], |
| 97 | + arg_group="Properties", |
| 98 | + help="This property allows you to specify the OS type of the VMs/VMSS for which this profile can be used against. Possible values are: 'Windows' or 'Linux'", |
| 99 | + enum={"Linux": "Linux", "Windows": "Windows"}, |
| 100 | + ) |
| 101 | + return cls._args_schema |
| 102 | + |
| 103 | + def _execute_operations(self): |
| 104 | + self.pre_operations() |
| 105 | + yield self.GalleryInVMAccessControlProfilesCreateOrUpdate(ctx=self.ctx)() |
| 106 | + self.post_operations() |
| 107 | + |
| 108 | + @register_callback |
| 109 | + def pre_operations(self): |
| 110 | + pass |
| 111 | + |
| 112 | + @register_callback |
| 113 | + def post_operations(self): |
| 114 | + pass |
| 115 | + |
| 116 | + def _output(self, *args, **kwargs): |
| 117 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) |
| 118 | + return result |
| 119 | + |
| 120 | + class GalleryInVMAccessControlProfilesCreateOrUpdate(AAZHttpOperation): |
| 121 | + CLIENT_TYPE = "MgmtClient" |
| 122 | + |
| 123 | + def __call__(self, *args, **kwargs): |
| 124 | + request = self.make_request() |
| 125 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 126 | + if session.http_response.status_code in [202]: |
| 127 | + return self.client.build_lro_polling( |
| 128 | + self.ctx.args.no_wait, |
| 129 | + session, |
| 130 | + self.on_200_201, |
| 131 | + self.on_error, |
| 132 | + lro_options={"final-state-via": "azure-async-operation"}, |
| 133 | + path_format_arguments=self.url_parameters, |
| 134 | + ) |
| 135 | + if session.http_response.status_code in [200, 201]: |
| 136 | + return self.client.build_lro_polling( |
| 137 | + self.ctx.args.no_wait, |
| 138 | + session, |
| 139 | + self.on_200_201, |
| 140 | + self.on_error, |
| 141 | + lro_options={"final-state-via": "azure-async-operation"}, |
| 142 | + path_format_arguments=self.url_parameters, |
| 143 | + ) |
| 144 | + |
| 145 | + return self.on_error(session.http_response) |
| 146 | + |
| 147 | + @property |
| 148 | + def url(self): |
| 149 | + return self.client.format_url( |
| 150 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{inVMAccessControlProfileName}", |
| 151 | + **self.url_parameters |
| 152 | + ) |
| 153 | + |
| 154 | + @property |
| 155 | + def method(self): |
| 156 | + return "PUT" |
| 157 | + |
| 158 | + @property |
| 159 | + def error_format(self): |
| 160 | + return "ODataV4Format" |
| 161 | + |
| 162 | + @property |
| 163 | + def url_parameters(self): |
| 164 | + parameters = { |
| 165 | + **self.serialize_url_param( |
| 166 | + "galleryName", self.ctx.args.gallery_name, |
| 167 | + required=True, |
| 168 | + ), |
| 169 | + **self.serialize_url_param( |
| 170 | + "inVMAccessControlProfileName", self.ctx.args.name, |
| 171 | + required=True, |
| 172 | + ), |
| 173 | + **self.serialize_url_param( |
| 174 | + "resourceGroupName", self.ctx.args.resource_group, |
| 175 | + required=True, |
| 176 | + ), |
| 177 | + **self.serialize_url_param( |
| 178 | + "subscriptionId", self.ctx.subscription_id, |
| 179 | + required=True, |
| 180 | + ), |
| 181 | + } |
| 182 | + return parameters |
| 183 | + |
| 184 | + @property |
| 185 | + def query_parameters(self): |
| 186 | + parameters = { |
| 187 | + **self.serialize_query_param( |
| 188 | + "api-version", "2024-03-03", |
| 189 | + required=True, |
| 190 | + ), |
| 191 | + } |
| 192 | + return parameters |
| 193 | + |
| 194 | + @property |
| 195 | + def header_parameters(self): |
| 196 | + parameters = { |
| 197 | + **self.serialize_header_param( |
| 198 | + "Content-Type", "application/json", |
| 199 | + ), |
| 200 | + **self.serialize_header_param( |
| 201 | + "Accept", "application/json", |
| 202 | + ), |
| 203 | + } |
| 204 | + return parameters |
| 205 | + |
| 206 | + @property |
| 207 | + def content(self): |
| 208 | + _content_value, _builder = self.new_content_builder( |
| 209 | + self.ctx.args, |
| 210 | + typ=AAZObjectType, |
| 211 | + typ_kwargs={"flags": {"required": True, "client_flatten": True}} |
| 212 | + ) |
| 213 | + _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) |
| 214 | + _builder.set_prop("properties", AAZObjectType) |
| 215 | + |
| 216 | + properties = _builder.get(".properties") |
| 217 | + if properties is not None: |
| 218 | + properties.set_prop("applicableHostEndpoint", AAZStrType, ".applicable_host_endpoint", typ_kwargs={"flags": {"required": True}}) |
| 219 | + properties.set_prop("description", AAZStrType, ".description") |
| 220 | + properties.set_prop("osType", AAZStrType, ".os_type", typ_kwargs={"flags": {"required": True}}) |
| 221 | + |
| 222 | + return self.serialize_content(_content_value) |
| 223 | + |
| 224 | + def on_200_201(self, session): |
| 225 | + data = self.deserialize_http_content(session) |
| 226 | + self.ctx.set_var( |
| 227 | + "instance", |
| 228 | + data, |
| 229 | + schema_builder=self._build_schema_on_200_201 |
| 230 | + ) |
| 231 | + |
| 232 | + _schema_on_200_201 = None |
| 233 | + |
| 234 | + @classmethod |
| 235 | + def _build_schema_on_200_201(cls): |
| 236 | + if cls._schema_on_200_201 is not None: |
| 237 | + return cls._schema_on_200_201 |
| 238 | + |
| 239 | + cls._schema_on_200_201 = AAZObjectType() |
| 240 | + |
| 241 | + _schema_on_200_201 = cls._schema_on_200_201 |
| 242 | + _schema_on_200_201.id = AAZStrType( |
| 243 | + flags={"read_only": True}, |
| 244 | + ) |
| 245 | + _schema_on_200_201.location = AAZStrType( |
| 246 | + flags={"required": True}, |
| 247 | + ) |
| 248 | + _schema_on_200_201.name = AAZStrType( |
| 249 | + flags={"read_only": True}, |
| 250 | + ) |
| 251 | + _schema_on_200_201.properties = AAZObjectType() |
| 252 | + _schema_on_200_201.tags = AAZDictType() |
| 253 | + _schema_on_200_201.type = AAZStrType( |
| 254 | + flags={"read_only": True}, |
| 255 | + ) |
| 256 | + |
| 257 | + properties = cls._schema_on_200_201.properties |
| 258 | + properties.applicable_host_endpoint = AAZStrType( |
| 259 | + serialized_name="applicableHostEndpoint", |
| 260 | + flags={"required": True}, |
| 261 | + ) |
| 262 | + properties.description = AAZStrType() |
| 263 | + properties.os_type = AAZStrType( |
| 264 | + serialized_name="osType", |
| 265 | + flags={"required": True}, |
| 266 | + ) |
| 267 | + properties.provisioning_state = AAZStrType( |
| 268 | + serialized_name="provisioningState", |
| 269 | + flags={"read_only": True}, |
| 270 | + ) |
| 271 | + |
| 272 | + tags = cls._schema_on_200_201.tags |
| 273 | + tags.Element = AAZStrType() |
| 274 | + |
| 275 | + return cls._schema_on_200_201 |
| 276 | + |
| 277 | + |
| 278 | +class _CreateHelper: |
| 279 | + """Helper class for Create""" |
| 280 | + |
| 281 | + |
| 282 | +__all__ = ["Create"] |
0 commit comments