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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"network asg address-prefix-set",
is_preview=True,
)
class __CMDGroup(AAZCommandGroup):
"""Manage address prefix sets in an application security group."""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -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 *
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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"]
Loading
Loading