Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 12 additions & 0 deletions src/nsp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Release History
===============
===============

##### 1.0.0
++++++
New commands added:
* perimeter associable-resource-type: list
* perimeter logging-configuration: list

Existing commands updated:
* Flattened output reponse for all commands.

Removed commands:
* perimeter onboarded-resources: list

##### 1.0.0b3
++++++
New commands added:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"network perimeter",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Network Security Perimeters
"""Manage Network Security Perimeters.
"""
pass

Expand Down
1 change: 1 addition & 0 deletions src/nsp/azext_nsp/aaz/latest/network/perimeter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
from ._delete import *
from ._list import *
from ._show import *
from ._wait import *
25 changes: 16 additions & 9 deletions src/nsp/azext_nsp/aaz/latest/network/perimeter/_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"network perimeter create",
)
class Create(AAZCommand):
"""Creates a Network Security Perimeter.
"""Create a network security perimeter.

:example: Create a Network Security Perimeter
:example: Create a network security perimeter
az network perimeter create -n MyPerimeter -g MyResourceGroup -l northcentralus
"""

_aaz_info = {
"version": "2023-08-01-preview",
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2023-08-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2024-07-01"],
]
}

Expand All @@ -48,6 +48,10 @@ def _build_arguments_schema(cls, *args, **kwargs):
options=["-n", "--name", "--perimeter-name"],
help="The name of the network security perimeter.",
required=True,
fmt=AAZStrArgFormat(
pattern="(^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*[a-zA-Z0-9_]+$)|(^[a-zA-Z0-9]$)",
max_length=80,
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
Expand Down Expand Up @@ -87,7 +91,7 @@ def post_operations(self):
pass

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

class NetworkSecurityPerimetersCreateOrUpdate(AAZHttpOperation):
Expand Down Expand Up @@ -138,7 +142,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-08-01-preview",
"api-version", "2024-07-01",
required=True,
),
}
Expand All @@ -164,7 +168,6 @@ def content(self):
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("location", AAZStrType, ".location")
_builder.set_prop("name", AAZStrType, ".perimeter_name")
_builder.set_prop("tags", AAZDictType, ".tags")

tags = _builder.get(".tags")
Expand Down Expand Up @@ -195,8 +198,12 @@ def _build_schema_on_200_201(cls):
flags={"read_only": True},
)
_schema_on_200_201.location = AAZStrType()
_schema_on_200_201.name = AAZStrType()
_schema_on_200_201.properties = AAZObjectType()
_schema_on_200_201.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200_201.tags = AAZDictType()
_schema_on_200_201.type = AAZStrType(
flags={"read_only": True},
Expand Down
55 changes: 45 additions & 10 deletions src/nsp/azext_nsp/aaz/latest/network/perimeter/_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@
confirmation="Are you sure you want to perform this operation?",
)
class Delete(AAZCommand):
"""Deletes a network security perimeter.
"""Delete a network security perimeter.

:example: Delete a Network Security Perimeter
:example: Delete a network security perimeter
az network perimeter delete -g MyResourceGroup -n MyPerimeter
"""

_aaz_info = {
"version": "2023-08-01-preview",
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2023-08-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2024-07-01"],
]
}

AZ_SUPPORT_NO_WAIT = True

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

_args_schema = None

Expand All @@ -50,15 +51,23 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="The name of the network security perimeter.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
pattern="(^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*[a-zA-Z0-9_]+$)|(^[a-zA-Z0-9]$)",
max_length=80,
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.force_deletion = AAZBoolArg(
options=["--force-deletion"],
help="Deletes the resource even if it contains any child associations.",
)
return cls._args_schema

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

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

return self.on_error(session.http_response)

Expand Down Expand Up @@ -119,7 +151,10 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-08-01-preview",
"forceDeletion", self.ctx.args.force_deletion,
),
**self.serialize_query_param(
"api-version", "2024-07-01",
required=True,
),
}
Expand Down
32 changes: 20 additions & 12 deletions src/nsp/azext_nsp/aaz/latest/network/perimeter/_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"network perimeter list",
)
class List(AAZCommand):
"""List all network security perimeters in a subscription.
"""List all network security perimeters.

:example: List Network Security Perimeters
:example: List all a network security perimeters
az network perimeter list -g MyResourceGroup
"""

_aaz_info = {
"version": "2023-08-01-preview",
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/providers/microsoft.network/networksecurityperimeters", "2023-08-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters", "2023-08-01-preview"],
["mgmt-plane", "/subscriptions/{}/providers/microsoft.network/networksecurityperimeters", "2024-07-01"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters", "2024-07-01"],
]
}

Expand Down Expand Up @@ -80,7 +80,7 @@ def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=False)
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

Expand Down Expand Up @@ -134,7 +134,7 @@ def query_parameters(self):
"$top", self.ctx.args.top,
),
**self.serialize_query_param(
"api-version", "2023-08-01-preview",
"api-version", "2024-07-01",
required=True,
),
}
Expand Down Expand Up @@ -180,8 +180,12 @@ def _build_schema_on_200(cls):
flags={"read_only": True},
)
_element.location = AAZStrType()
_element.name = AAZStrType()
_element.properties = AAZObjectType()
_element.name = AAZStrType(
flags={"read_only": True},
)
_element.properties = AAZObjectType(
flags={"client_flatten": True},
)
_element.tags = AAZDictType()
_element.type = AAZStrType(
flags={"read_only": True},
Expand Down Expand Up @@ -248,7 +252,7 @@ def query_parameters(self):
"$top", self.ctx.args.top,
),
**self.serialize_query_param(
"api-version", "2023-08-01-preview",
"api-version", "2024-07-01",
required=True,
),
}
Expand Down Expand Up @@ -294,8 +298,12 @@ def _build_schema_on_200(cls):
flags={"read_only": True},
)
_element.location = AAZStrType()
_element.name = AAZStrType()
_element.properties = AAZObjectType()
_element.name = AAZStrType(
flags={"read_only": True},
)
_element.properties = AAZObjectType(
flags={"client_flatten": True},
)
_element.tags = AAZDictType()
_element.type = AAZStrType(
flags={"read_only": True},
Expand Down
24 changes: 16 additions & 8 deletions src/nsp/azext_nsp/aaz/latest/network/perimeter/_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"network perimeter show",
)
class Show(AAZCommand):
"""Gets the specified network security perimeter by the name.
"""Get a network security perimeter.

:example: Get the Network Security Perimeter
:example: Get a network security perimeter
az network perimeter show -g MyResourceGroup -n MyPerimeter
"""

_aaz_info = {
"version": "2023-08-01-preview",
"version": "2024-07-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2023-08-01-preview"],
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2024-07-01"],
]
}

Expand All @@ -49,6 +49,10 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="The name of the network security perimeter.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
pattern="(^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*[a-zA-Z0-9_]+$)|(^[a-zA-Z0-9]$)",
max_length=80,
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
Expand All @@ -69,7 +73,7 @@ def post_operations(self):
pass

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

class NetworkSecurityPerimetersGet(AAZHttpOperation):
Expand Down Expand Up @@ -120,7 +124,7 @@ def url_parameters(self):
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2023-08-01-preview",
"api-version", "2024-07-01",
required=True,
),
}
Expand Down Expand Up @@ -157,8 +161,12 @@ def _build_schema_on_200(cls):
flags={"read_only": True},
)
_schema_on_200.location = AAZStrType()
_schema_on_200.name = AAZStrType()
_schema_on_200.properties = AAZObjectType()
_schema_on_200.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200.properties = AAZObjectType(
flags={"client_flatten": True},
)
_schema_on_200.tags = AAZDictType()
_schema_on_200.type = AAZStrType(
flags={"read_only": True},
Expand Down
Loading
Loading