diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/__init__.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/__init__.py index db73033039b..5d894d5160d 100644 --- a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/__init__.py @@ -15,3 +15,12 @@ from ._show import * from ._update import * from ._wait import * +from .address_prefix_set import ( + __CMDGroup as AddressPrefixSetGroup, + Create as AddressPrefixSetCreate, + Delete as AddressPrefixSetDelete, + List as AddressPrefixSetList, + Show as AddressPrefixSetShow, + Update as AddressPrefixSetUpdate, + Wait as AddressPrefixSetWait, +) diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__cmd_group.py new file mode 100644 index 00000000000..a0a00b2bfc4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__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( + "network asg address-prefix-set", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage address prefix sets in an application security group.""" + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__init__.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/__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/network/aaz/latest/network/asg/address_prefix_set/_create.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_create.py new file mode 100644 index 00000000000..a936ff6bbd0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_create.py @@ -0,0 +1,190 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "network asg address-prefix-set create", + is_preview=True, +) +class Create(AAZCommand): + """Create an address prefix set in an application security group. + + :example: Create an address prefix set. + az network asg address-prefix-set create -g MyResourceGroup --asg-name MyAsg -n MyPrefixSet --address-prefixes 10.0.0.0/16 2001:db8::/32 + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets/{}", "2025-09-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) + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name", "--address-prefix-set-name"], + help="Name of the address prefix set.", + required=True, + id_part="child_name_1", + ) + _args_schema.address_prefixes = AAZListArg( + options=["--address-prefixes"], + help="Space-separated list of IPv4 or IPv6 address prefixes in CIDR notation.", + required=True, + ) + _args_schema.address_prefixes.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.AddressPrefixSetsCreateOrUpdate(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): + return self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + + class AddressPrefixSetsCreateOrUpdate(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, 201, 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": "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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Content-Type", "application/json"), + **self.serialize_header_param("Accept", "application/json"), + } + + @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("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop( + "addressPrefixes", AAZListType, ".address_prefixes", + typ_kwargs={"flags": {"required": True}} + ) + address_prefixes = properties.get(".addressPrefixes") + if address_prefixes is not None: + address_prefixes.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() + _AddressPrefixSetSchema.build(cls._schema_on_200_201) + return cls._schema_on_200_201 + + +class _AddressPrefixSetSchema: + @staticmethod + def build(schema): + schema.etag = AAZStrType(flags={"read_only": True}) + schema.id = AAZStrType() + schema.name = AAZStrType(flags={"read_only": True}) + schema.properties = AAZObjectType(flags={"client_flatten": True}) + schema.type = AAZStrType(flags={"read_only": True}) + schema.properties.address_prefixes = AAZListType(serialized_name="addressPrefixes") + schema.properties.address_prefixes.Element = AAZStrType() + schema.properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_delete.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_delete.py new file mode 100644 index 00000000000..6a9bc00d00d --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_delete.py @@ -0,0 +1,127 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "network asg address-prefix-set delete", + is_preview=True, +) +class Delete(AAZCommand): + """Delete an address prefix set. + + :example: Delete an address prefix set. + az network asg address-prefix-set delete -g MyResourceGroup --asg-name MyAsg -n MyPrefixSet + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets/{}", "2025-09-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) + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name", "--address-prefix-set-name"], + help="Name of the address prefix set.", + required=True, + id_part="child_name_1", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.AddressPrefixSetsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class AddressPrefixSetsDelete(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, 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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + def on_204(self, session): + pass + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_list.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_list.py new file mode 100644 index 00000000000..459ef7f656a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_list.py @@ -0,0 +1,141 @@ +# -------------------------------------------------------------------------------------------- +# 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 * +from ._create import _AddressPrefixSetSchema + + +@register_command( + "network asg address-prefix-set list", + is_preview=True, +) +class List(AAZCommand): + """List address prefix sets in an application security group. + + :example: List address prefix sets. + az network asg address-prefix-set list -g MyResourceGroup --asg-name MyAsg + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets", "2025-09-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) + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AddressPrefixSetsList(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 AddressPrefixSetsList(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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Accept", "application/json"), + } + + 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() + cls._schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + flags={"read_only": True}, + ) + cls._schema_on_200.value = AAZListType() + cls._schema_on_200.value.Element = AAZObjectType() + _AddressPrefixSetSchema.build(cls._schema_on_200.value.Element) + return cls._schema_on_200 + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_show.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_show.py new file mode 100644 index 00000000000..6dde9bf69de --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_show.py @@ -0,0 +1,140 @@ +# -------------------------------------------------------------------------------------------- +# 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 * +from ._create import _AddressPrefixSetSchema + + +@register_command( + "network asg address-prefix-set show", + is_preview=True, +) +class Show(AAZCommand): + """Get details of an address prefix set. + + :example: Get an address prefix set. + az network asg address-prefix-set show -g MyResourceGroup --asg-name MyAsg -n MyPrefixSet + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets/{}", "2025-09-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) + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name", "--address-prefix-set-name"], + help="Name of the address prefix set.", + required=True, + id_part="child_name_1", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AddressPrefixSetsGet(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): + return self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + + class AddressPrefixSetsGet(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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Accept", "application/json"), + } + + 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() + _AddressPrefixSetSchema.build(cls._schema_on_200) + return cls._schema_on_200 + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_update.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_update.py new file mode 100644 index 00000000000..c13cba13ff2 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_update.py @@ -0,0 +1,276 @@ +# -------------------------------------------------------------------------------------------- +# 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 * +from ._create import _AddressPrefixSetSchema + + +@register_command( + "network asg address-prefix-set update", + is_preview=True, +) +class Update(AAZCommand): + """Update an address prefix set. + + :example: Update address prefixes in an address prefix set. + az network asg address-prefix-set update -g MyResourceGroup --asg-name MyAsg -n MyPrefixSet --address-prefixes 10.0.0.0/8 2001:db8::/32 + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets/{}", "2025-09-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) + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name", "--address-prefix-set-name"], + help="Name of the address prefix set.", + required=True, + id_part="child_name_1", + ) + _args_schema.address_prefixes = AAZListArg( + options=["--address-prefixes"], + help="Space-separated list of IPv4 or IPv6 address prefixes in CIDR notation.", + nullable=True, + ) + _args_schema.address_prefixes.Element = AAZStrArg(nullable=True) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AddressPrefixSetsGet(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.AddressPrefixSetsCreateOrUpdate(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): + return self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + + class AddressPrefixSetsGet(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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Accept", "application/json"), + } + + 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() + _AddressPrefixSetSchema.build(cls._schema_on_200) + return cls._schema_on_200 + + class AddressPrefixSetsCreateOrUpdate(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, 201, 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": "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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Content-Type", "application/json"), + **self.serialize_header_param("Accept", "application/json"), + } + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + typ=AAZObjectType, + ) + _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop( + "addressPrefixes", AAZListType, ".address_prefixes", + typ_kwargs={"flags": {"required": True}} + ) + address_prefixes = properties.get(".addressPrefixes") + if address_prefixes is not None: + address_prefixes.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() + _AddressPrefixSetSchema.build(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("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("addressPrefixes", AAZListType, ".address_prefixes") + address_prefixes = properties.get(".addressPrefixes") + if address_prefixes is not None: + address_prefixes.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 + ) + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_wait.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_wait.py new file mode 100644 index 00000000000..16dd89cdfd4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/asg/address_prefix_set/_wait.py @@ -0,0 +1,135 @@ +# -------------------------------------------------------------------------------------------- +# 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 * +from ._create import _AddressPrefixSetSchema + + +@register_command( + "network asg address-prefix-set wait", + is_preview=True, +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until an address prefix set condition is met.""" + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/applicationsecuritygroups/{}/addressprefixsets/{}", "2025-09-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) + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.application_security_group_name = AAZStrArg( + options=["--asg-name", "--application-security-group-name"], + help="Name of the application security group.", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name", "--address-prefix-set-name"], + help="Name of the address prefix set.", + required=True, + id_part="child_name_1", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AddressPrefixSetsGet(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): + return self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + + class AddressPrefixSetsGet(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.Network/applicationSecurityGroups/{applicationSecurityGroupName}/addressPrefixSets/{addressPrefixSetName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("addressPrefixSetName", self.ctx.args.name, required=True), + **self.serialize_url_param( + "applicationSecurityGroupName", self.ctx.args.application_security_group_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), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Accept", "application/json"), + } + + 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() + _AddressPrefixSetSchema.build(cls._schema_on_200) + return cls._schema_on_200 + + +__all__ = ["Wait"] diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/__init__.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/__init__.py index c352aa0e33a..8f973e5ab5a 100644 --- a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/__init__.py @@ -14,6 +14,7 @@ from ._delete import * from ._list import * from ._list_endpoint_services import * +from ._move_ip_configurations import * from ._show import * from ._update import * from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_move_ip_configurations.py b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_move_ip_configurations.py new file mode 100644 index 00000000000..a5e78f438b9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet/_move_ip_configurations.py @@ -0,0 +1,185 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "network vnet move-ip-configurations", + is_preview=True, +) +class MoveIpConfigurations(AAZCommand): + """Move IP configurations from one virtual network to another. + + :example: Move an IP configuration to a virtual network. + az network vnet move-ip-configurations -g MyResourceGroup -n MyVnet --move-ip-configuration-items "[0].source-ip-configuration.id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/nic1/ipConfigurations/ipconfig1" "[0].target-ip-configuration.id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/nic2/ipConfigurations/ipconfig2" + """ + + _aaz_info = { + "version": "2025-09-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/virtualnetworks/{}/moveipconfigurations", "2025-09-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) + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg(required=True) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="Name of the virtual network.", + required=True, + id_part="name", + ) + _args_schema.move_ip_configuration_items = AAZListArg( + options=["--move-items", "--move-ip-configuration-items"], + help="List of source and target IP configuration resource ID pairs.", + required=True, + ) + _args_schema.move_ip_configuration_items.Element = AAZObjectArg() + _element = _args_schema.move_ip_configuration_items.Element + _element.source_ip_configuration = AAZObjectArg( + options=["source-ip-configuration"], + help="Source IP configuration.", + required=True, + ) + _element.source_ip_configuration.id = AAZResourceIdArg( + options=["id"], + help="ARM resource ID of the source IP configuration.", + required=True, + ) + _element.target_ip_configuration = AAZObjectArg( + options=["target-ip-configuration"], + help="Target IP configuration.", + required=True, + ) + _element.target_ip_configuration.id = AAZResourceIdArg( + options=["id"], + help="ARM resource ID of the target IP configuration.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.VirtualNetworksMoveIpConfigurations(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class VirtualNetworksMoveIpConfigurations(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, 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, + ) + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/moveIpConfigurations", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + return { + **self.serialize_url_param("resourceGroupName", self.ctx.args.resource_group, required=True), + **self.serialize_url_param("subscriptionId", self.ctx.subscription_id, required=True), + **self.serialize_url_param("virtualNetworkName", self.ctx.args.name, required=True), + } + + @property + def query_parameters(self): + return { + **self.serialize_query_param("api-version", "2025-09-01", required=True), + } + + @property + def header_parameters(self): + return { + **self.serialize_header_param("Content-Type", "application/json"), + **self.serialize_header_param("Accept", "application/json"), + } + + @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( + "moveIpConfigurationItems", AAZListType, ".move_ip_configuration_items", + typ_kwargs={"flags": {"required": True}} + ) + items = _builder.get(".moveIpConfigurationItems") + if items is not None: + items.set_elements(AAZObjectType, ".") + element = _builder.get(".moveIpConfigurationItems[]") + if element is not None: + element.set_prop( + "sourceIpConfiguration", AAZObjectType, ".source_ip_configuration", + typ_kwargs={"flags": {"required": True}} + ) + source = element.get(".sourceIpConfiguration") + if source is not None: + source.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) + element.set_prop( + "targetIpConfiguration", AAZObjectType, ".target_ip_configuration", + typ_kwargs={"flags": {"required": True}} + ) + target = element.get(".targetIpConfiguration") + if target is not None: + target.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) + return self.serialize_content(_content_value) + + def on_200(self, session): + pass + + +__all__ = ["MoveIpConfigurations"] diff --git a/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py b/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py index fe9a59d9dcd..23b58153b22 100644 --- a/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py +++ b/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py @@ -125,5 +125,55 @@ def test_no_shared_key_without_cert_auth_should_raise(self): self.assertIn('--shared-key is required', str(ctx.exception)) +class TestNetwork20250901AAZCommands(unittest.TestCase): + def test_parent_and_child_commands_are_registered(self): + from azure.cli.core.mock import DummyCli + from azure.cli.command_modules.network import NetworkCommandsLoader + + parent_loader = NetworkCommandsLoader(cli_ctx=DummyCli()) + parent_commands = parent_loader.load_command_table(['network', 'asg', 'create']) + self.assertIn('network asg create', parent_commands) + + child_loader = NetworkCommandsLoader(cli_ctx=DummyCli()) + child_commands = child_loader.load_command_table( + ['network', 'asg', 'address-prefix-set', 'create'] + ) + self.assertIn('network asg address-prefix-set create', child_commands) + + def test_address_prefix_set_command_schemas(self): + from azure.cli.command_modules.network.aaz.latest.network.asg.address_prefix_set._create import Create + from azure.cli.command_modules.network.aaz.latest.network.asg.address_prefix_set._update import Update + + create_schema = Create._build_arguments_schema() + self.assertTrue(create_schema.resource_group._required) + self.assertTrue(create_schema.application_security_group_name._required) + self.assertTrue(create_schema.name._required) + self.assertTrue(create_schema.address_prefixes._required) + self.assertEqual(create_schema.address_prefixes._options, ['--address-prefixes']) + self.assertEqual(Create._aaz_info['version'], '2025-09-01') + + update_schema = Update._build_arguments_schema() + self.assertFalse(update_schema.address_prefixes._required) + self.assertTrue(update_schema.address_prefixes._nullable) + self.assertTrue(Update.AZ_SUPPORT_GENERIC_UPDATE) + + def test_move_ip_configurations_command_schema(self): + from azure.cli.command_modules.network.aaz.latest.network.vnet._move_ip_configurations import ( + MoveIpConfigurations, + ) + + schema = MoveIpConfigurations._build_arguments_schema() + self.assertTrue(schema.move_ip_configuration_items._required) + self.assertIn('--move-items', schema.move_ip_configuration_items._options) + item = schema.move_ip_configuration_items.Element + self.assertTrue(item.source_ip_configuration._required) + self.assertTrue(item.source_ip_configuration.id._required) + self.assertTrue(item.target_ip_configuration._required) + self.assertTrue(item.target_ip_configuration.id._required) + self.assertEqual(MoveIpConfigurations._aaz_info['version'], '2025-09-01') + operation = MoveIpConfigurations.VirtualNetworksMoveIpConfigurations + self.assertEqual(operation.method.fget(None), 'POST') + + if __name__ == '__main__': unittest.main()