diff --git a/src/azure-cli-core/azure/cli/core/commandIndex.latest.json b/src/azure-cli-core/azure/cli/core/commandIndex.latest.json index 8544d53989f..648c0957f58 100644 --- a/src/azure-cli-core/azure/cli/core/commandIndex.latest.json +++ b/src/azure-cli-core/azure/cli/core/commandIndex.latest.json @@ -313,6 +313,9 @@ "webapp": [ "azure.cli.command_modules.appservice", "azure.cli.command_modules.serviceconnector" + ], + "interconnect-block": [ + "azure.cli.command_modules.vm" ] } } diff --git a/src/azure-cli-core/azure/cli/core/helpIndex.latest.json b/src/azure-cli-core/azure/cli/core/helpIndex.latest.json index d3bfea42881..b7e325784b3 100644 --- a/src/azure-cli-core/azure/cli/core/helpIndex.latest.json +++ b/src/azure-cli-core/azure/cli/core/helpIndex.latest.json @@ -358,6 +358,10 @@ "webapp": { "summary": "Manage web apps.", "tags": "" + }, + "interconnect-block": { + "summary": "Manage Interconnect Block.", + "tags": "" } }, "commands": { diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__cmd_group.py new file mode 100644 index 00000000000..fdf72d0d450 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__cmd_group.py @@ -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( + "interconnect-block", +) +class __CMDGroup(AAZCommandGroup): + """Manage Interconnect Block + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__init__.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_create.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_create.py new file mode 100644 index 00000000000..5d73c2d4726 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_create.py @@ -0,0 +1,450 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block create", +) +class Create(AAZCommand): + """Create an Interconnect Block. When updating an Interconnect Block, only tags and sku-capacity may be modified. + + :example: Creates a new InterconnectBlock resource. + az interconnect-block create --name training-icb-001 --resource-group ai-training-rg --location eastus --zone 1 --sku-name Standard_ND128isr_GB300_v6 --sku-capacity 36 --interconnect-group-id "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/network-rg/providers/Microsoft.Network/interconnectGroups/training-ig" --tags Environment=Production Workload=AI-Training CostCenter=ML-Engineering + """ + + _aaz_info = { + "version": "2026-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks/{}", "2026-03-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.interconnect_block_name = AAZStrArg( + options=["-n", "--name", "--interconnect-block-name"], + help="The name of the Interconnect Block.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "InterconnectGroup" + + _args_schema = cls._args_schema + _args_schema.interconnect_group_id = AAZStrArg( + options=["--group-id", "--interconnect-group-id"], + arg_group="InterconnectGroup", + help="The ARM resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...", + ) + + # define Arg Group "Placement" + + _args_schema = cls._args_schema + _args_schema.placement_exclude_zones = AAZListArg( + options=["--exclude-zones", "--placement-exclude-zones"], + arg_group="Placement", + help="This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any'/'Auto', availability zone selected by the system must not be present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not provided, all availability zones in region will be considered for selection.", + ) + _args_schema.placement_include_zones = AAZListArg( + options=["--include-zones", "--placement-include-zones"], + arg_group="Placement", + help="This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any'/'Auto', availability zone selected by the system must be present in the list of availability zones passed with 'includeZones'. If 'includeZones' is not provided, all availability zones in region will be considered for selection.", + ) + _args_schema.placement_zone_placement_policy = AAZStrArg( + options=["--zone-placement-policy", "--placement-zone-placement-policy"], + arg_group="Placement", + help="Specifies the policy for resource's placement in availability zone. Possible values are: **Any** (used for Virtual Machines), **Auto** (used for Virtual Machine Scale Sets) - An availability zone will be automatically picked by system as part of resource creation.", + enum={"Any": "Any", "Auto": "Auto"}, + ) + + placement_exclude_zones = cls._args_schema.placement_exclude_zones + placement_exclude_zones.Element = AAZStrArg() + + placement_include_zones = cls._args_schema.placement_include_zones + placement_include_zones.Element = AAZStrArg() + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Resource", + help="The geo-location where the resource lives", + required=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + ) + _args_schema.zones = AAZListArg( + options=["--zones"], + arg_group="Resource", + help="The availability zones.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + zones = cls._args_schema.zones + zones.Element = AAZStrArg() + + # define Arg Group "Sku" + + _args_schema = cls._args_schema + _args_schema.sku_capacity = AAZIntArg( + options=["--sku-capacity"], + arg_group="Sku", + help="Specifies the number of virtual machines in the scale set.", + ) + _args_schema.sku_name = AAZStrArg( + options=["--sku-name"], + arg_group="Sku", + help="The sku name.", + ) + _args_schema.sku_tier = AAZStrArg( + options=["--sku-tier"], + arg_group="Sku", + help="Specifies the tier of virtual machines in a scale set. Possible Values: Standard, Basic", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.InterconnectBlocksCreateOrUpdate(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 InterconnectBlocksCreateOrUpdate(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_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + 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/interconnectBlocks/{interconnectBlockName}", + **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( + "interconnectBlockName", self.ctx.args.interconnect_block_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", "2026-03-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("placement", AAZObjectType) + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("sku", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + _builder.set_prop("zones", AAZListType, ".zones") + + placement = _builder.get(".placement") + if placement is not None: + placement.set_prop("excludeZones", AAZListType, ".placement_exclude_zones") + placement.set_prop("includeZones", AAZListType, ".placement_include_zones") + placement.set_prop("zonePlacementPolicy", AAZStrType, ".placement_zone_placement_policy") + + exclude_zones = _builder.get(".placement.excludeZones") + if exclude_zones is not None: + exclude_zones.set_elements(AAZStrType, ".") + + include_zones = _builder.get(".placement.includeZones") + if include_zones is not None: + include_zones.set_elements(AAZStrType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("interconnectGroup", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + + interconnect_group = _builder.get(".properties.interconnectGroup") + if interconnect_group is not None: + interconnect_group.set_prop("id", AAZStrType, ".interconnect_group_id") + + sku = _builder.get(".sku") + if sku is not None: + sku.set_prop("capacity", AAZIntType, ".sku_capacity") + sku.set_prop("name", AAZStrType, ".sku_name") + sku.set_prop("tier", AAZStrType, ".sku_tier") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + zones = _builder.get(".zones") + if zones is not None: + zones.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.placement = AAZObjectType() + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.sku = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.zones = AAZListType() + + placement = cls._schema_on_200_201.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = cls._schema_on_200_201.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = cls._schema_on_200_201.placement.include_zones + include_zones.Element = AAZStrType() + + properties = cls._schema_on_200_201.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200_201.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = cls._schema_on_200_201.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = cls._schema_on_200_201.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = cls._schema_on_200_201.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200_201.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + zones = cls._schema_on_200_201.zones + zones.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_delete.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_delete.py new file mode 100644 index 00000000000..561305ea6e6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_delete.py @@ -0,0 +1,166 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an Interconnect Block. The operation is only allowed when there are no virtual machines or VMSS VM instances associated with the Interconnect Block. + + :example: Delete an Interconnect Block. + az interconnect-block delete --name training-icb-001 --resource-group ai-training-rg + + :example: Delete without confirmation + az interconnect-block delete --name training-icb-001 --resource-group ai-training-rg --yes + """ + + _aaz_info = { + "version": "2026-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks/{}", "2026-03-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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.interconnect_block_name = AAZStrArg( + options=["-n", "--name", "--interconnect-block-name"], + help="The name of the Interconnect Block.", + 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.InterconnectBlocksDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class InterconnectBlocksDelete(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": "location"}, + 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": "location"}, + 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": "location"}, + 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/interconnectBlocks/{interconnectBlockName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "interconnectBlockName", self.ctx.args.interconnect_block_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", "2026-03-01", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_list.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_list.py new file mode 100644 index 00000000000..a789d8c10fd --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_list.py @@ -0,0 +1,530 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block list", +) +class List(AAZCommand): + """List all of the Interconnect Blocks in the subscription. Use the nextLink property in the response to get the next page of Interconnect Blocks. + + :example: List all in subscription + az interconnect-block list + + :example: List by resource group + az interconnect-block list --resource-group ai-training-rg + + :example: List and filter by capacity + az interconnect-block list --resource-group ai-training-rg --query "[?sku.capacity>=36]" + """ + + _aaz_info = { + "version": "2026-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/interconnectblocks", "2026-03-01"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks", "2026-03-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(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.resource_group = AAZResourceGroupNameArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + if condition_0: + self.InterconnectBlocksListBySubscription(ctx=self.ctx)() + if condition_1: + self.InterconnectBlocksListByResourceGroup(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.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class InterconnectBlocksListBySubscription(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 [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/interconnectBlocks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **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", "2026-03-01", + 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.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.placement = AAZObjectType() + _element.properties = AAZObjectType() + _element.sku = AAZObjectType( + flags={"required": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + _element.zones = AAZListType() + + placement = cls._schema_on_200.value.Element.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = cls._schema_on_200.value.Element.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = cls._schema_on_200.value.Element.placement.include_zones + include_zones.Element = AAZStrType() + + properties = cls._schema_on_200.value.Element.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200.value.Element.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = cls._schema_on_200.value.Element.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = cls._schema_on_200.value.Element.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = cls._schema_on_200.value.Element.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + zones = cls._schema_on_200.value.Element.zones + zones.Element = AAZStrType() + + return cls._schema_on_200 + + class InterconnectBlocksListByResourceGroup(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 [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/interconnectBlocks", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **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", "2026-03-01", + 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.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.placement = AAZObjectType() + _element.properties = AAZObjectType() + _element.sku = AAZObjectType( + flags={"required": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + _element.zones = AAZListType() + + placement = cls._schema_on_200.value.Element.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = cls._schema_on_200.value.Element.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = cls._schema_on_200.value.Element.placement.include_zones + include_zones.Element = AAZStrType() + + properties = cls._schema_on_200.value.Element.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200.value.Element.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = cls._schema_on_200.value.Element.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = cls._schema_on_200.value.Element.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = cls._schema_on_200.value.Element.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.value.Element.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + zones = cls._schema_on_200.value.Element.zones + zones.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_show.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_show.py new file mode 100644 index 00000000000..e873341717d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_show.py @@ -0,0 +1,308 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block show", +) +class Show(AAZCommand): + """Get information about an Interconnect Block. + + :example: Get basic information + az interconnect-block show --name training-icb-001 --resource-group ai-training-rg + + :example: Get with instance view (includes runtime details) + az interconnect-block show --name training-icb-001 --resource-group ai-training-rg --expand instanceView + """ + + _aaz_info = { + "version": "2026-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks/{}", "2026-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return 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.interconnect_block_name = AAZStrArg( + options=["-n", "--name", "--interconnect-block-name"], + help="The name of the Interconnect Block.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="The expand expression to apply on the operation. 'instanceView' retrieves a snapshot of the runtime properties of the Interconnect Block that is managed by the platform and can change outside of control plane operations.", + enum={"instanceView": "instanceView"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InterconnectBlocksGet(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 InterconnectBlocksGet(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 [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/interconnectBlocks/{interconnectBlockName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "interconnectBlockName", self.ctx.args.interconnect_block_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( + "$expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2026-03-01", + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.placement = AAZObjectType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.zones = AAZListType() + + placement = cls._schema_on_200.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = cls._schema_on_200.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = cls._schema_on_200.placement.include_zones + include_zones.Element = AAZStrType() + + properties = cls._schema_on_200.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = cls._schema_on_200.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = cls._schema_on_200.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = cls._schema_on_200.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + zones = cls._schema_on_200.zones + zones.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_update.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_update.py new file mode 100644 index 00000000000..483fbfe4f7a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_update.py @@ -0,0 +1,596 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block update", +) +class Update(AAZCommand): + """Update an Interconnect Block. When updating an Interconnect Block, only tags and sku-capacity may be modified. + + :example: Update scale capacity + az interconnect-block update --name training-icb-001 --resource-group ai-training-rg --sku-capacity 54 + + :example: Update tags + az interconnect-block update --name training-icb-001 --resource-group ai-training-rg --tags Environment=Production Capacity=54-nodes LastScaled=$(date +%Y-%m-%d) + + :example: Update scale with no-wait + az interconnect-block update --name training-icb-001 --resource-group ai-training-rg --sku-capacity 72 --no-wait + """ + + _aaz_info = { + "version": "2026-03-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks/{}", "2026-03-01"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = 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.interconnect_block_name = AAZStrArg( + options=["-n", "--name", "--interconnect-block-name"], + help="The name of the Interconnect Block.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Placement" + + _args_schema = cls._args_schema + _args_schema.placement_exclude_zones = AAZListArg( + options=["--exclude-zones", "--placement-exclude-zones"], + arg_group="Placement", + help="This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any'/'Auto', availability zone selected by the system must not be present in the list of availability zones passed with 'excludeZones'. If 'excludeZones' is not provided, all availability zones in region will be considered for selection.", + nullable=True, + ) + _args_schema.placement_include_zones = AAZListArg( + options=["--include-zones", "--placement-include-zones"], + arg_group="Placement", + help="This property supplements the 'zonePlacementPolicy' property. If 'zonePlacementPolicy' is set to 'Any'/'Auto', availability zone selected by the system must be present in the list of availability zones passed with 'includeZones'. If 'includeZones' is not provided, all availability zones in region will be considered for selection.", + nullable=True, + ) + _args_schema.placement_zone_placement_policy = AAZStrArg( + options=["--zone-placement-policy", "--placement-zone-placement-policy"], + arg_group="Placement", + help="Specifies the policy for resource's placement in availability zone. Possible values are: **Any** (used for Virtual Machines), **Auto** (used for Virtual Machine Scale Sets) - An availability zone will be automatically picked by system as part of resource creation.", + nullable=True, + enum={"Any": "Any", "Auto": "Auto"}, + ) + + placement_exclude_zones = cls._args_schema.placement_exclude_zones + placement_exclude_zones.Element = AAZStrArg( + nullable=True, + ) + + placement_include_zones = cls._args_schema.placement_include_zones + placement_include_zones.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Resource" + + _args_schema = cls._args_schema + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Resource", + help="Resource tags.", + nullable=True, + ) + _args_schema.zones = AAZListArg( + options=["--zones"], + arg_group="Resource", + help="The availability zones.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + zones = cls._args_schema.zones + zones.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Sku" + + _args_schema = cls._args_schema + _args_schema.sku_capacity = AAZIntArg( + options=["--sku-capacity"], + arg_group="Sku", + help="Specifies the number of virtual machines in the scale set.", + nullable=True, + ) + _args_schema.sku_name = AAZStrArg( + options=["--sku-name"], + arg_group="Sku", + help="The sku name.", + nullable=True, + ) + _args_schema.sku_tier = AAZStrArg( + options=["--sku-tier"], + arg_group="Sku", + help="Specifies the tier of virtual machines in a scale set. Possible Values: Standard, Basic", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InterconnectBlocksGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.InterconnectBlocksCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class InterconnectBlocksGet(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 [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/interconnectBlocks/{interconnectBlockName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "interconnectBlockName", self.ctx.args.interconnect_block_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", "2026-03-01", + 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() + _UpdateHelper._build_schema_interconnect_block_read(cls._schema_on_200) + + return cls._schema_on_200 + + class InterconnectBlocksCreateOrUpdate(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_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + 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/interconnectBlocks/{interconnectBlockName}", + **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( + "interconnectBlockName", self.ctx.args.interconnect_block_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", "2026-03-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, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_interconnect_block_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("placement", AAZObjectType) + _builder.set_prop("sku", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + _builder.set_prop("zones", AAZListType, ".zones") + + placement = _builder.get(".placement") + if placement is not None: + placement.set_prop("excludeZones", AAZListType, ".placement_exclude_zones") + placement.set_prop("includeZones", AAZListType, ".placement_include_zones") + placement.set_prop("zonePlacementPolicy", AAZStrType, ".placement_zone_placement_policy") + + exclude_zones = _builder.get(".placement.excludeZones") + if exclude_zones is not None: + exclude_zones.set_elements(AAZStrType, ".") + + include_zones = _builder.get(".placement.includeZones") + if include_zones is not None: + include_zones.set_elements(AAZStrType, ".") + + sku = _builder.get(".sku") + if sku is not None: + sku.set_prop("capacity", AAZIntType, ".sku_capacity") + sku.set_prop("name", AAZStrType, ".sku_name") + sku.set_prop("tier", AAZStrType, ".sku_tier") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + zones = _builder.get(".zones") + if zones is not None: + zones.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_interconnect_block_read = None + + @classmethod + def _build_schema_interconnect_block_read(cls, _schema): + if cls._schema_interconnect_block_read is not None: + _schema.id = cls._schema_interconnect_block_read.id + _schema.location = cls._schema_interconnect_block_read.location + _schema.name = cls._schema_interconnect_block_read.name + _schema.placement = cls._schema_interconnect_block_read.placement + _schema.properties = cls._schema_interconnect_block_read.properties + _schema.sku = cls._schema_interconnect_block_read.sku + _schema.system_data = cls._schema_interconnect_block_read.system_data + _schema.tags = cls._schema_interconnect_block_read.tags + _schema.type = cls._schema_interconnect_block_read.type + _schema.zones = cls._schema_interconnect_block_read.zones + return + + cls._schema_interconnect_block_read = _schema_interconnect_block_read = AAZObjectType() + + interconnect_block_read = _schema_interconnect_block_read + interconnect_block_read.id = AAZStrType( + flags={"read_only": True}, + ) + interconnect_block_read.location = AAZStrType( + flags={"required": True}, + ) + interconnect_block_read.name = AAZStrType( + flags={"read_only": True}, + ) + interconnect_block_read.placement = AAZObjectType() + interconnect_block_read.properties = AAZObjectType() + interconnect_block_read.sku = AAZObjectType( + flags={"required": True}, + ) + interconnect_block_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + interconnect_block_read.tags = AAZDictType() + interconnect_block_read.type = AAZStrType( + flags={"read_only": True}, + ) + interconnect_block_read.zones = AAZListType() + + placement = _schema_interconnect_block_read.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = _schema_interconnect_block_read.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = _schema_interconnect_block_read.placement.include_zones + include_zones.Element = AAZStrType() + + properties = _schema_interconnect_block_read.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = _schema_interconnect_block_read.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = _schema_interconnect_block_read.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = _schema_interconnect_block_read.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = _schema_interconnect_block_read.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = _schema_interconnect_block_read.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = _schema_interconnect_block_read.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = _schema_interconnect_block_read.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = _schema_interconnect_block_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_interconnect_block_read.tags + tags.Element = AAZStrType() + + zones = _schema_interconnect_block_read.zones + zones.Element = AAZStrType() + + _schema.id = cls._schema_interconnect_block_read.id + _schema.location = cls._schema_interconnect_block_read.location + _schema.name = cls._schema_interconnect_block_read.name + _schema.placement = cls._schema_interconnect_block_read.placement + _schema.properties = cls._schema_interconnect_block_read.properties + _schema.sku = cls._schema_interconnect_block_read.sku + _schema.system_data = cls._schema_interconnect_block_read.system_data + _schema.tags = cls._schema_interconnect_block_read.tags + _schema.type = cls._schema_interconnect_block_read.type + _schema.zones = cls._schema_interconnect_block_read.zones + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_wait.py b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_wait.py new file mode 100644 index 00000000000..cc8e3dfbbda --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/aaz/latest/interconnect_block/_wait.py @@ -0,0 +1,301 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "interconnect-block wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/interconnectblocks/{}", "2026-03-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return 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.interconnect_block_name = AAZStrArg( + options=["-n", "--name", "--interconnect-block-name"], + help="The name of the Interconnect Block.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.expand = AAZStrArg( + options=["--expand"], + help="The expand expression to apply on the operation. 'instanceView' retrieves a snapshot of the runtime properties of the Interconnect Block that is managed by the platform and can change outside of control plane operations.", + enum={"instanceView": "instanceView"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.InterconnectBlocksGet(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=False) + return result + + class InterconnectBlocksGet(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 [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/interconnectBlocks/{interconnectBlockName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "interconnectBlockName", self.ctx.args.interconnect_block_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( + "$expand", self.ctx.args.expand, + ), + **self.serialize_query_param( + "api-version", "2026-03-01", + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.placement = AAZObjectType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.sku = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.zones = AAZListType() + + placement = cls._schema_on_200.placement + placement.exclude_zones = AAZListType( + serialized_name="excludeZones", + ) + placement.include_zones = AAZListType( + serialized_name="includeZones", + ) + placement.zone_placement_policy = AAZStrType( + serialized_name="zonePlacementPolicy", + ) + + exclude_zones = cls._schema_on_200.placement.exclude_zones + exclude_zones.Element = AAZStrType() + + include_zones = cls._schema_on_200.placement.include_zones + include_zones.Element = AAZStrType() + + properties = cls._schema_on_200.properties + properties.instance_view = AAZObjectType( + serialized_name="instanceView", + flags={"read_only": True}, + ) + properties.interconnect_block_id = AAZStrType( + serialized_name="interconnectBlockId", + flags={"read_only": True}, + ) + properties.interconnect_group = AAZObjectType( + serialized_name="interconnectGroup", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.provisioning_time = AAZStrType( + serialized_name="provisioningTime", + flags={"read_only": True}, + ) + properties.time_created = AAZStrType( + serialized_name="timeCreated", + flags={"read_only": True}, + ) + properties.virtual_machines_associated = AAZListType( + serialized_name="virtualMachinesAssociated", + flags={"read_only": True}, + ) + + instance_view = cls._schema_on_200.properties.instance_view + instance_view.current_capacity = AAZIntType( + serialized_name="currentCapacity", + flags={"read_only": True}, + ) + instance_view.statuses = AAZListType( + flags={"read_only": True}, + ) + + statuses = cls._schema_on_200.properties.instance_view.statuses + statuses.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.instance_view.statuses.Element + _element.code = AAZStrType() + _element.display_status = AAZStrType( + serialized_name="displayStatus", + ) + _element.level = AAZStrType() + _element.message = AAZStrType() + _element.time = AAZStrType() + + interconnect_group = cls._schema_on_200.properties.interconnect_group + interconnect_group.id = AAZStrType() + + virtual_machines_associated = cls._schema_on_200.properties.virtual_machines_associated + virtual_machines_associated.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.virtual_machines_associated.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + + sku = cls._schema_on_200.sku + sku.capacity = AAZIntType() + sku.name = AAZStrType() + sku.tier = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + zones = cls._schema_on_200.zones + zones.Element = AAZStrType() + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"]