Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,6 @@
crafted: true
"""

helps['disk-access create'] = """
type: command
short-summary: Create a disk access resource.
examples:
- name: Create a disk access resource.
text: >
az disk-access create -g MyResourceGroup -l centraluseuap -n MyDiskAccess
"""

helps['disk-access update'] = """
type: command
short-summary: Update a disk access resource.
examples:
- name: Update a disk access resource.
text: >
az disk-access update -g MyResourceGroup -n MyDiskAccess --tags tag1=val1 tag2=val2
"""

helps['disk-access wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of a disk access is met.
examples:
- name: Place the CLI in a waiting state until the disk access is created with 'provisioningState' at 'Succeeded'.
text: |
az disk-access wait --created -g MyResourceGroup -n MyDiskAccess
"""

helps['disk-encryption-set create'] = """
type: command
short-summary: Create a disk encryption set.
Expand Down
7 changes: 0 additions & 7 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1510,13 +1510,6 @@ def load_arguments(self, _):
'Check out help for more examples')
# endregion

# region DiskAccess
with self.argument_context('disk-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disk_accesses') as c:
c.argument('disk_access_name', arg_type=name_arg_type, help='Name of the disk access resource.', id_part='name')
c.argument('location', validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
# endRegion

# region Capacity
with self.argument_context('capacity reservation group') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
from ._wait import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
# --------------------------------------------------------------------------------------------
# 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(
"disk-access create",
)
class Create(AAZCommand):
"""Create a disk access resource

:example: Create a disk access resource.
az disk-access create -g MyResourceGroup -l centraluseuap -n MyDiskAccess
"""

_aaz_info = {
"version": "2020-05-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/diskaccesses/{}", "2020-05-01"],
]
}

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.disk_access_name = AAZStrArg(
options=["-n", "--name", "--disk-access-name"],
help="The name of the disk access resource that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.",
required=True,
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)

# define Arg Group "DiskAccess"

_args_schema = cls._args_schema
_args_schema.location = AAZResourceLocationArg(
arg_group="DiskAccess",
help="Resource location",
required=True,
fmt=AAZResourceLocationArgFormat(
resource_group_arg="resource_group",
),
)
_args_schema.tags = AAZDictArg(
options=["--tags"],
arg_group="DiskAccess",
help="Resource tags",
)

tags = cls._args_schema.tags
tags.Element = AAZStrArg()
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
yield self.DiskAccessesCreateOrUpdate(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 DiskAccessesCreateOrUpdate(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,
)

return self.on_error(session.http_response)

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

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

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

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"diskAccessName", self.ctx.args.disk_access_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", "2020-05-01",
required=True,
),
}
return parameters

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

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("tags", AAZDictType, ".tags")

tags = _builder.get(".tags")
if tags is not None:
tags.set_elements(AAZStrType, ".")

return self.serialize_content(_content_value)

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()
_CreateHelper._build_schema_disk_access_read(cls._schema_on_200)

return cls._schema_on_200


class _CreateHelper:
"""Helper class for Create"""

_schema_disk_access_read = None

@classmethod
def _build_schema_disk_access_read(cls, _schema):
if cls._schema_disk_access_read is not None:
_schema.id = cls._schema_disk_access_read.id
_schema.location = cls._schema_disk_access_read.location
_schema.name = cls._schema_disk_access_read.name
_schema.properties = cls._schema_disk_access_read.properties
_schema.tags = cls._schema_disk_access_read.tags
_schema.type = cls._schema_disk_access_read.type
return

cls._schema_disk_access_read = _schema_disk_access_read = AAZObjectType()

disk_access_read = _schema_disk_access_read
disk_access_read.id = AAZStrType(
flags={"read_only": True},
)
disk_access_read.location = AAZStrType(
flags={"required": True},
)
disk_access_read.name = AAZStrType(
flags={"read_only": True},
)
disk_access_read.properties = AAZObjectType(
flags={"client_flatten": True},
)
disk_access_read.tags = AAZDictType()
disk_access_read.type = AAZStrType(
flags={"read_only": True},
)

properties = _schema_disk_access_read.properties
properties.private_endpoint_connections = AAZListType(
serialized_name="privateEndpointConnections",
flags={"read_only": True},
)
properties.provisioning_state = AAZStrType(
serialized_name="provisioningState",
flags={"read_only": True},
)
properties.time_created = AAZStrType(
serialized_name="timeCreated",
flags={"read_only": True},
)

private_endpoint_connections = _schema_disk_access_read.properties.private_endpoint_connections
private_endpoint_connections.Element = AAZObjectType()

_element = _schema_disk_access_read.properties.private_endpoint_connections.Element
_element.id = AAZStrType(
flags={"read_only": True},
)
_element.name = AAZStrType(
flags={"read_only": True},
)
_element.properties = AAZObjectType(
flags={"client_flatten": True},
)
_element.type = AAZStrType(
flags={"read_only": True},
)

properties = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties
properties.private_endpoint = AAZObjectType(
serialized_name="privateEndpoint",
)
properties.private_link_service_connection_state = AAZObjectType(
serialized_name="privateLinkServiceConnectionState",
flags={"required": True},
)
properties.provisioning_state = AAZStrType(
serialized_name="provisioningState",
flags={"read_only": True},
)

private_endpoint = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties.private_endpoint
private_endpoint.id = AAZStrType(
flags={"read_only": True},
)

private_link_service_connection_state = _schema_disk_access_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state
private_link_service_connection_state.actions_required = AAZStrType(
serialized_name="actionsRequired",
)
private_link_service_connection_state.description = AAZStrType()
private_link_service_connection_state.status = AAZStrType()

tags = _schema_disk_access_read.tags
tags.Element = AAZStrType()

_schema.id = cls._schema_disk_access_read.id
_schema.location = cls._schema_disk_access_read.location
_schema.name = cls._schema_disk_access_read.name
_schema.properties = cls._schema_disk_access_read.properties
_schema.tags = cls._schema_disk_access_read.tags
_schema.type = cls._schema_disk_access_read.type


__all__ = ["Create"]
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class List(AAZCommand):
]
}

AZ_SUPPORT_PAGINATION = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_paging(self._execute_operations, self._output)
Expand Down
Loading