Skip to content

Commit

Permalink
{Compute} az disk-encryption-set, az sig image-version and az image: …
Browse files Browse the repository at this point in the history
…Migrate commands using CodeGen V2 (#26951)
  • Loading branch information
yanzhudd authored Jul 25, 2023
1 parent bcf1ded commit 2460fb5
Show file tree
Hide file tree
Showing 64 changed files with 16,056 additions and 3,943 deletions.
63 changes: 0 additions & 63 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@
az disk-access wait --created -g MyResourceGroup -n MyDiskAccess
"""

helps['disk-encryption-set'] = """
type: group
short-summary: Disk Encryption Set resource.
"""

helps['disk-encryption-set create'] = """
type: command
short-summary: Create a disk encryption set.
Expand All @@ -210,31 +205,6 @@
text: az disk-encryption-set create --resource-group MyResourceGroup --name MyDiskEncryptionSet --key-url MyKey --source-vault MyVault --encryption-type EncryptionAtRestWithPlatformAndCustomerKeys
"""

helps['disk-encryption-set delete'] = """
type: command
short-summary: Delete a disk encryption set.
examples:
- name: Delete a disk encryption set. (autogenerated)
text: |
az disk-encryption-set delete --name MyDiskEncryptionSet --resource-group MyResourceGroup
crafted: true
"""

helps['disk-encryption-set list'] = """
type: command
short-summary: List disk encryption sets.
"""

helps['disk-encryption-set show'] = """
type: command
short-summary: Get information of a disk encryption sets.
examples:
- name: Get information of a disk encryption sets (autogenerated)
text: |
az disk-encryption-set show --name MyDiskEncryptionSet --resource-group MyResourceGroup
crafted: true
"""

helps['disk-encryption-set update'] = """
type: command
short-summary: Update a disk encryption set.
Expand Down Expand Up @@ -295,11 +265,6 @@
az disk-encryption-set identity show --name MyDiskEncryptionSet --resource-group MyResourceGroup
"""

helps['image'] = """
type: group
short-summary: Manage custom virtual machine images.
"""

helps['image create'] = """
type: command
short-summary: Create a custom Virtual Machine Image from managed disks or snapshots.
Expand All @@ -312,18 +277,6 @@
text: az image create -g MyResourceGroup -n image1 --source MyVm1
"""

helps['image list'] = """
type: command
short-summary: List custom VM images.
"""

helps['image show'] = """
type: command
parameters:
- name: --expand
short-summary: The expand expression to apply on the operation. Default value is None.
"""

helps['image builder'] = """
type: group
short-summary: Manage and build image builder templates.
Expand Down Expand Up @@ -981,11 +934,6 @@
--location myLocation
"""

helps['sig image-version'] = """
type: group
short-summary: Manage shared gallery image version with VM
"""

helps['sig image-version create'] = """
type: command
short-summary: create a new image version
Expand Down Expand Up @@ -1134,17 +1082,6 @@
--gallery-image-definition MyImage --location myLocation --shared-to tenant
"""

helps['sig image-version show-shared'] = """
type: command
short-summary: Get an image version in a gallery shared directly to your subscription or tenant
long-summary: Get an image version in a gallery shared directly to your subscription or tenant
examples:
- name: Get an image version in a gallery shared directly to your subscription or tenant in the given location.
text: |
az sig image-version show-shared --gallery-unique-name galleryUniqueName \\
--gallery-image-definition MyImage --gallery-image-version 1.0.0 --location myLocation
"""

helps['sig image-version update'] = """
type: command
short-summary: update a share image version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"image",
)
class __CMDGroup(AAZCommandGroup):
"""Manage custom virtual machine images.
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._delete import *
from ._list import *
from ._show import *
from ._wait import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"image delete",
)
class Delete(AAZCommand):
"""Delete an Image.
"""

_aaz_info = {
"version": "2017-03-30",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/images/{}", "2017-03-30"],
]
}

AZ_SUPPORT_NO_WAIT = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_lro_poller(self._execute_operations, self._output)

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""

_args_schema = cls._args_schema
_args_schema.image_name = AAZStrArg(
options=["-n", "--name", "--image-name"],
help="The name of the image.",
required=True,
id_part="name",
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
yield self.ImagesDelete(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class ImagesDelete(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [202]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [200]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [204]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_204,
self.on_error,
lro_options={"final-state-via": "azure-async-operation"},
path_format_arguments=self.url_parameters,
)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}",
**self.url_parameters
)

@property
def method(self):
return "DELETE"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"imageName", self.ctx.args.image_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2017-03-30",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.end_time = AAZStrType(
serialized_name="endTime",
flags={"read_only": True},
)
_schema_on_200.error = AAZObjectType()
_schema_on_200.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200.start_time = AAZStrType(
serialized_name="startTime",
flags={"read_only": True},
)
_schema_on_200.status = AAZStrType(
flags={"read_only": True},
)

error = cls._schema_on_200.error
error.code = AAZStrType()
error.details = AAZListType()
error.innererror = AAZObjectType()
error.message = AAZStrType()
error.target = AAZStrType()

details = cls._schema_on_200.error.details
details.Element = AAZObjectType()

_element = cls._schema_on_200.error.details.Element
_element.code = AAZStrType()
_element.message = AAZStrType()
_element.target = AAZStrType()

innererror = cls._schema_on_200.error.innererror
innererror.errordetail = AAZStrType()
innererror.exceptiontype = AAZStrType()

return cls._schema_on_200

def on_204(self, session):
pass


class _DeleteHelper:
"""Helper class for Delete"""


__all__ = ["Delete"]
Loading

0 comments on commit 2460fb5

Please sign in to comment.