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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/nsp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Release History
===============
===============

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

Existing commands updated:
* perimeter delete: added --force-deletion parameter.
* 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 *
56 changes: 45 additions & 11 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 All @@ -59,6 +63,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.location = AAZResourceLocationArg(
arg_group="Parameters",
help="The location in which NSP is created.",
required=True,
fmt=AAZResourceLocationArgFormat(
resource_group_arg="resource_group",
),
Expand Down Expand Up @@ -87,7 +92,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 +143,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 @@ -163,8 +168,7 @@ def content(self):
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("location", AAZStrType, ".location")
_builder.set_prop("name", AAZStrType, ".perimeter_name")
_builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("tags", AAZDictType, ".tags")

tags = _builder.get(".tags")
Expand Down Expand Up @@ -194,9 +198,19 @@ def _build_schema_on_200_201(cls):
_schema_on_200_201.id = AAZStrType(
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.location = AAZStrType(
flags={"required": True},
)
_schema_on_200_201.name = AAZStrType(
flags={"read_only": True},
)
_schema_on_200_201.properties = AAZObjectType(
flags={"client_flatten": 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},
Expand All @@ -212,6 +226,26 @@ def _build_schema_on_200_201(cls):
flags={"read_only": True},
)

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()

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
Loading
Loading