From d3871e8c8151f9c17ccdc1b30e838ee6e5365620 Mon Sep 17 00:00:00 2001 From: nikhilsaxena2609 <101093751+nikhilsaxena2609@users.noreply.github.com> Date: Thu, 24 Nov 2022 14:49:10 +0530 Subject: [PATCH] Add Network Security Perimeter CLI (#5502) --- .github/CODEOWNERS | 2 + src/nsp/HISTORY.rst | 8 + src/nsp/README.md | 13 + src/nsp/azext_nsp/__init__.py | 42 + src/nsp/azext_nsp/_help.py | 11 + src/nsp/azext_nsp/_params.py | 13 + src/nsp/azext_nsp/aaz/__init__.py | 6 + src/nsp/azext_nsp/aaz/latest/__init__.py | 6 + .../aaz/latest/network/__cmd_group.py | 23 + .../azext_nsp/aaz/latest/network/__init__.py | 11 + .../latest/network/perimeter/__cmd_group.py | 23 + .../aaz/latest/network/perimeter/__init__.py | 15 + .../aaz/latest/network/perimeter/_create.py | 212 ++++ .../aaz/latest/network/perimeter/_delete.py | 125 +++ .../aaz/latest/network/perimeter/_list.py | 308 ++++++ .../aaz/latest/network/perimeter/_show.py | 173 ++++ .../perimeter/association/__cmd_group.py | 23 + .../network/perimeter/association/__init__.py | 17 + .../network/perimeter/association/_create.py | 301 ++++++ .../network/perimeter/association/_delete.py | 159 +++ .../network/perimeter/association/_list.py | 225 ++++ .../network/perimeter/association/_show.py | 209 ++++ .../network/perimeter/association/_update.py | 449 ++++++++ .../network/perimeter/association/_wait.py | 205 ++++ .../onboarded_resources/__cmd_group.py | 23 + .../perimeter/onboarded_resources/__init__.py | 12 + .../perimeter/onboarded_resources/_list.py | 181 ++++ .../network/perimeter/profile/__cmd_group.py | 23 + .../network/perimeter/profile/__init__.py | 15 + .../network/perimeter/profile/_create.py | 218 ++++ .../network/perimeter/profile/_delete.py | 135 +++ .../latest/network/perimeter/profile/_list.py | 195 ++++ .../latest/network/perimeter/profile/_show.py | 179 ++++ .../profile/access_rule/__cmd_group.py | 23 + .../perimeter/profile/access_rule/__init__.py | 16 + .../perimeter/profile/access_rule/_create.py | 360 +++++++ .../perimeter/profile/access_rule/_delete.py | 145 +++ .../perimeter/profile/access_rule/_list.py | 240 +++++ .../perimeter/profile/access_rule/_show.py | 225 ++++ .../perimeter/profile/access_rule/_update.py | 512 ++++++++++ src/nsp/azext_nsp/azext_metadata.json | 4 + src/nsp/azext_nsp/commands.py | 15 + src/nsp/azext_nsp/custom.py | 14 + src/nsp/azext_nsp/tests/__init__.py | 6 + src/nsp/azext_nsp/tests/latest/__init__.py | 6 + .../recordings/test_nsp_accessrule_crud.yaml | 567 ++++++++++ .../test_nsp_accessrule_inbound.yaml | 485 +++++++++ .../recordings/test_nsp_association_crud.yaml | 965 ++++++++++++++++++ .../latest/recordings/test_nsp_crud.yaml | 282 +++++ .../recordings/test_nsp_profile_crud.yaml | 284 ++++++ src/nsp/azext_nsp/tests/latest/test_nsp.py | 144 +++ src/nsp/setup.cfg | 1 + src/nsp/setup.py | 49 + 53 files changed, 7903 insertions(+) create mode 100644 src/nsp/HISTORY.rst create mode 100644 src/nsp/README.md create mode 100644 src/nsp/azext_nsp/__init__.py create mode 100644 src/nsp/azext_nsp/_help.py create mode 100644 src/nsp/azext_nsp/_params.py create mode 100644 src/nsp/azext_nsp/aaz/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/_create.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/_delete.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/_list.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/_show.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_create.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_delete.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_list.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_show.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_update.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_wait.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/_list.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_create.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_delete.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_list.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_show.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__cmd_group.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__init__.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_create.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_delete.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_list.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_show.py create mode 100644 src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_update.py create mode 100644 src/nsp/azext_nsp/azext_metadata.json create mode 100644 src/nsp/azext_nsp/commands.py create mode 100644 src/nsp/azext_nsp/custom.py create mode 100644 src/nsp/azext_nsp/tests/__init__.py create mode 100644 src/nsp/azext_nsp/tests/latest/__init__.py create mode 100644 src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_crud.yaml create mode 100644 src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_inbound.yaml create mode 100644 src/nsp/azext_nsp/tests/latest/recordings/test_nsp_association_crud.yaml create mode 100644 src/nsp/azext_nsp/tests/latest/recordings/test_nsp_crud.yaml create mode 100644 src/nsp/azext_nsp/tests/latest/recordings/test_nsp_profile_crud.yaml create mode 100644 src/nsp/azext_nsp/tests/latest/test_nsp.py create mode 100644 src/nsp/setup.cfg create mode 100644 src/nsp/setup.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6fd29c2e006..2ccd01c723d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -253,3 +253,5 @@ /src/scenario-guide/ @zhoxing-ms @ReaNAiveD /src/dynatrace/ @jsntcy + +/src/nsp/ @nikhilsaxena2609 diff --git a/src/nsp/HISTORY.rst b/src/nsp/HISTORY.rst new file mode 100644 index 00000000000..8c34bccfff8 --- /dev/null +++ b/src/nsp/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/nsp/README.md b/src/nsp/README.md new file mode 100644 index 00000000000..16e90d024e2 --- /dev/null +++ b/src/nsp/README.md @@ -0,0 +1,13 @@ +# Azure CLI NSP Extension # +This is an extension to Azure CLI to manage NSP resources. + +## How to use ## +Install this extension using the below CLI command +``` +az extension add --name nsp +``` + +Then, call it as you would any other az command: +``` +az network manager -h +``` \ No newline at end of file diff --git a/src/nsp/azext_nsp/__init__.py b/src/nsp/azext_nsp/__init__.py new file mode 100644 index 00000000000..c6bc81fda4c --- /dev/null +++ b/src/nsp/azext_nsp/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_nsp._help import helps # pylint: disable=unused-import + + +class NspCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_nsp.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_nsp.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_nsp._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = NspCommandsLoader diff --git a/src/nsp/azext_nsp/_help.py b/src/nsp/azext_nsp/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/nsp/azext_nsp/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/nsp/azext_nsp/_params.py b/src/nsp/azext_nsp/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/nsp/azext_nsp/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/nsp/azext_nsp/aaz/__init__.py b/src/nsp/azext_nsp/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/nsp/azext_nsp/aaz/latest/__init__.py b/src/nsp/azext_nsp/aaz/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/nsp/azext_nsp/aaz/latest/network/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/__cmd_group.py new file mode 100644 index 00000000000..5093d2928ba --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/__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", +) +class __CMDGroup(AAZCommandGroup): + """Manage Azure Network resources. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/__cmd_group.py new file mode 100644 index 00000000000..d6ba9595326 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/__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 perimeter", +) +class __CMDGroup(AAZCommandGroup): + """Manage Network Security Perimeters + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/__init__.py new file mode 100644 index 00000000000..efc3964e3fb --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/_create.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_create.py new file mode 100644 index 00000000000..7c508f2265d --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_create.py @@ -0,0 +1,212 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter create", +) +class Create(AAZCommand): + """Creates a Network Security Perimeter. + + :example: Create a Network Security Perimeter + az network perimeter create -n MyPerimeter -g MyResourceGroup -l northcentralus + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["-n", "--name", "--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="The location in which NSP is created.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.NetworkSecurityPerimetersCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NetworkSecurityPerimetersCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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") + _builder.set_prop("name", AAZStrType, ".perimeter_name") + _builder.set_prop("tags", AAZDictType, ".tags") + + tags = _builder.get(".tags") + if tags is not None: + tags.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() + _schema_on_200_201.name = AAZStrType() + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +__all__ = ["Create"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/_delete.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_delete.py new file mode 100644 index 00000000000..1ae90eae9e9 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_delete.py @@ -0,0 +1,125 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Deletes a network security perimeter. + + :example: Delete a Network Security Perimeter + az network perimeter delete -g MyResourceGroup -n MyPerimeter + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2021-02-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return 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.perimeter_name = AAZStrArg( + options=["-n", "--name", "--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NetworkSecurityPerimetersDelete(ctx=self.ctx)() + + class NetworkSecurityPerimetersDelete(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) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +__all__ = ["Delete"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/_list.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_list.py new file mode 100644 index 00000000000..70526f8e251 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_list.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( + "network perimeter list", +) +class List(AAZCommand): + """List all network security perimeters in a subscription. + + :example: List Network Security Perimeters + az network perimeter list -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.network/networksecurityperimeters", "2021-02-01-preview"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters", "2021-02-01-preview"], + ] + } + + 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() + _args_schema.skip_token = AAZStrArg( + options=["--skip-token"], + help="SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="An optional query parameter which specifies the maximum number of records to be returned by the server.", + fmt=AAZIntArgFormat( + maximum=20, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.NetworkSecurityPerimetersList(ctx=self.ctx)() + if condition_1: + self.NetworkSecurityPerimetersListBySubscription(ctx=self.ctx)() + + 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 NetworkSecurityPerimetersList(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/networkSecurityPerimeters", + **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( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class NetworkSecurityPerimetersListBySubscription(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.Network/networkSecurityPerimeters", + **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( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["List"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/_show.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_show.py new file mode 100644 index 00000000000..e105f94535a --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/_show.py @@ -0,0 +1,173 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter show", +) +class Show(AAZCommand): + """Gets the specified network security perimeter by the name. + + :example: Get the Network Security Perimeter + az network perimeter show -g MyResourceGroup -n MyPerimeter + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["-n", "--name", "--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NetworkSecurityPerimetersGet(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NetworkSecurityPerimetersGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["Show"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__cmd_group.py new file mode 100644 index 00000000000..e59b2d6a4f1 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__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 perimeter association", +) +class __CMDGroup(AAZCommandGroup): + """Manage NSP Associations + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/__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/nsp/azext_nsp/aaz/latest/network/perimeter/association/_create.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_create.py new file mode 100644 index 00000000000..77b0bc869f6 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_create.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( + "network perimeter association create", +) +class Create(AAZCommand): + """Creates or updates a NSP resource association. + + :example: Create NSP Association + az network perimeter association create -n MyAssociation --perimeter-name MyPerimeter -g MyResourceGroup --access-mode Learning --private-link-resource "{id:}" --profile "{id:}" + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/resourceassociations/{}", "2021-02-01-preview"], + ] + } + + 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.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the NSP association.", + required=True, + id_part="child_name_1", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.access_mode = AAZStrArg( + options=["--access-mode"], + arg_group="Properties", + help="Access mode on the association.", + enum={"Audit": "Audit", "Enforced": "Enforced", "Learning": "Learning"}, + ) + _args_schema.private_link_resource = AAZObjectArg( + options=["--private-link-resource"], + arg_group="Properties", + help="The PaaS resource to be associated.", + ) + cls._build_args_sub_resource_create(_args_schema.private_link_resource) + _args_schema.profile = AAZObjectArg( + options=["--profile"], + arg_group="Properties", + help="Profile id to which the PaaS resource is associated.", + ) + cls._build_args_sub_resource_create(_args_schema.profile) + return cls._args_schema + + _args_sub_resource_create = None + + @classmethod + def _build_args_sub_resource_create(cls, _schema): + if cls._args_sub_resource_create is not None: + _schema.id = cls._args_sub_resource_create.id + return + + cls._args_sub_resource_create = AAZObjectArg() + + sub_resource_create = cls._args_sub_resource_create + sub_resource_create.id = AAZStrArg( + options=["id"], + help="Resource ID.", + ) + + _schema.id = cls._args_sub_resource_create.id + + def _execute_operations(self): + self.NspAssociationsCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAssociationsCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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") + _builder.set_prop("name", AAZStrType, ".association_name") + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("accessMode", AAZStrType, ".access_mode") + _build_schema_sub_resource_create(properties.set_prop("privateLinkResource", AAZObjectType, ".private_link_resource")) + _build_schema_sub_resource_create(properties.set_prop("profile", AAZObjectType, ".profile")) + + tags = _builder.get(".tags") + if tags is not None: + tags.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() + _schema_on_200_201.name = AAZStrType() + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.access_mode = AAZStrType( + serialized_name="accessMode", + ) + properties.has_provisioning_issues = AAZStrType( + serialized_name="hasProvisioningIssues", + flags={"read_only": True}, + ) + properties.private_link_resource = AAZObjectType( + serialized_name="privateLinkResource", + ) + _build_schema_sub_resource_read(properties.private_link_resource) + properties.profile = AAZObjectType() + _build_schema_sub_resource_read(properties.profile) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +def _build_schema_sub_resource_create(_builder): + if _builder is None: + return + _builder.set_prop("id", AAZStrType, ".id") + + +_schema_sub_resource_read = None + + +def _build_schema_sub_resource_read(_schema): + global _schema_sub_resource_read + if _schema_sub_resource_read is not None: + _schema.id = _schema_sub_resource_read.id + return + + _schema_sub_resource_read = AAZObjectType() + + sub_resource_read = _schema_sub_resource_read + sub_resource_read.id = AAZStrType() + + _schema.id = _schema_sub_resource_read.id + + +__all__ = ["Create"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_delete.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_delete.py new file mode 100644 index 00000000000..8e1ab8e33b4 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_delete.py @@ -0,0 +1,159 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter association delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Deletes an NSP association resource. + + :example: Delete NSP Association + az network perimeter association delete -n MyAssociation --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/resourceassociations/{}", "2021-02-01-preview"], + ] + } + + 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.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the NSP association.", + required=True, + id_part="child_name_1", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + yield self.NspAssociationsDelete(ctx=self.ctx)() + + class NspAssociationsDelete(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": "azure-async-operation"}, + 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": "azure-async-operation"}, + 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": "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/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +__all__ = ["Delete"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_list.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_list.py new file mode 100644 index 00000000000..3eb46dc0886 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_list.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter association list", +) +class List(AAZCommand): + """Lists the NSP resource associations. + + :example: List NSP Associations inside a Perimeter + az network perimeter association list --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/resourceassociations", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.skip_token = AAZStrArg( + options=["--skip-token"], + help="SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="An optional query parameter which specifies the maximum number of records to be returned by the server.", + fmt=AAZIntArgFormat( + maximum=20, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAssociationsList(ctx=self.ctx)() + + 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 NspAssociationsList(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.access_mode = AAZStrType( + serialized_name="accessMode", + ) + properties.has_provisioning_issues = AAZStrType( + serialized_name="hasProvisioningIssues", + flags={"read_only": True}, + ) + properties.private_link_resource = AAZObjectType( + serialized_name="privateLinkResource", + ) + _build_schema_sub_resource_read(properties.private_link_resource) + properties.profile = AAZObjectType() + _build_schema_sub_resource_read(properties.profile) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +_schema_sub_resource_read = None + + +def _build_schema_sub_resource_read(_schema): + global _schema_sub_resource_read + if _schema_sub_resource_read is not None: + _schema.id = _schema_sub_resource_read.id + return + + _schema_sub_resource_read = AAZObjectType() + + sub_resource_read = _schema_sub_resource_read + sub_resource_read.id = AAZStrType() + + _schema.id = _schema_sub_resource_read.id + + +__all__ = ["List"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_show.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_show.py new file mode 100644 index 00000000000..651de0f0660 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_show.py @@ -0,0 +1,209 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter association show", +) +class Show(AAZCommand): + """Gets the specified NSP association by name. + + :example: Get NSP Association + az network perimeter association show -n MyAssociation --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/resourceassociations/{}", "2021-02-01-preview"], + ] + } + + 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.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the NSP association.", + required=True, + id_part="child_name_1", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAssociationsGet(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAssociationsGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.access_mode = AAZStrType( + serialized_name="accessMode", + ) + properties.has_provisioning_issues = AAZStrType( + serialized_name="hasProvisioningIssues", + flags={"read_only": True}, + ) + properties.private_link_resource = AAZObjectType( + serialized_name="privateLinkResource", + ) + _build_schema_sub_resource_read(properties.private_link_resource) + properties.profile = AAZObjectType() + _build_schema_sub_resource_read(properties.profile) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +_schema_sub_resource_read = None + + +def _build_schema_sub_resource_read(_schema): + global _schema_sub_resource_read + if _schema_sub_resource_read is not None: + _schema.id = _schema_sub_resource_read.id + return + + _schema_sub_resource_read = AAZObjectType() + + sub_resource_read = _schema_sub_resource_read + sub_resource_read.id = AAZStrType() + + _schema.id = _schema_sub_resource_read.id + + +__all__ = ["Show"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_update.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_update.py new file mode 100644 index 00000000000..9b63b3d83c8 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_update.py @@ -0,0 +1,449 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter association update", +) +class Update(AAZCommand): + """Creates or updates a NSP resource association. + + :example: Update NSP Association + az network perimeter association update --name MyAssociation --perimeter-name MyPerimeter --resource-group MyResourceGroup --access-mode Enforced --private-link-resource id=" --profile id="ProfileArmID" + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/resourceassociations/{}", "2021-02-01-preview"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + 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.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the NSP association.", + required=True, + id_part="child_name_1", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location.", + nullable=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.access_mode = AAZStrArg( + options=["--access-mode"], + arg_group="Properties", + help="Access mode on the association.", + nullable=True, + enum={"Audit": "Audit", "Enforced": "Enforced", "Learning": "Learning"}, + ) + _args_schema.private_link_resource = AAZObjectArg( + options=["--private-link-resource"], + arg_group="Properties", + help="The PaaS resource to be associated.", + nullable=True, + ) + cls._build_args_sub_resource_update(_args_schema.private_link_resource) + _args_schema.profile = AAZObjectArg( + options=["--profile"], + arg_group="Properties", + help="Profile id to which the PaaS resource is associated.", + nullable=True, + ) + cls._build_args_sub_resource_update(_args_schema.profile) + return cls._args_schema + + _args_sub_resource_update = None + + @classmethod + def _build_args_sub_resource_update(cls, _schema): + if cls._args_sub_resource_update is not None: + _schema.id = cls._args_sub_resource_update.id + return + + cls._args_sub_resource_update = AAZObjectArg( + nullable=True, + ) + + sub_resource_update = cls._args_sub_resource_update + sub_resource_update.id = AAZStrArg( + options=["id"], + help="Resource ID.", + nullable=True, + ) + + _schema.id = cls._args_sub_resource_update.id + + def _execute_operations(self): + self.NspAssociationsGet(ctx=self.ctx)() + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.NspAssociationsCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAssociationsGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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() + _build_schema_nsp_association_read(cls._schema_on_200) + + return cls._schema_on_200 + + class NspAssociationsCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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() + _build_schema_nsp_association_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("location", AAZStrType, ".location") + _builder.set_prop("name", AAZStrType, ".association_name") + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("accessMode", AAZStrType, ".access_mode") + _build_schema_sub_resource_update(properties.set_prop("privateLinkResource", AAZObjectType, ".private_link_resource")) + _build_schema_sub_resource_update(properties.set_prop("profile", AAZObjectType, ".profile")) + + tags = _builder.get(".tags") + if tags is not None: + tags.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 + ) + + +def _build_schema_sub_resource_update(_builder): + if _builder is None: + return + _builder.set_prop("id", AAZStrType, ".id") + + +_schema_nsp_association_read = None + + +def _build_schema_nsp_association_read(_schema): + global _schema_nsp_association_read + if _schema_nsp_association_read is not None: + _schema.id = _schema_nsp_association_read.id + _schema.location = _schema_nsp_association_read.location + _schema.name = _schema_nsp_association_read.name + _schema.properties = _schema_nsp_association_read.properties + _schema.tags = _schema_nsp_association_read.tags + _schema.type = _schema_nsp_association_read.type + return + + _schema_nsp_association_read = AAZObjectType() + + nsp_association_read = _schema_nsp_association_read + nsp_association_read.id = AAZStrType( + flags={"read_only": True}, + ) + nsp_association_read.location = AAZStrType() + nsp_association_read.name = AAZStrType() + nsp_association_read.properties = AAZObjectType() + nsp_association_read.tags = AAZDictType() + nsp_association_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_nsp_association_read.properties + properties.access_mode = AAZStrType( + serialized_name="accessMode", + ) + properties.has_provisioning_issues = AAZStrType( + serialized_name="hasProvisioningIssues", + flags={"read_only": True}, + ) + properties.private_link_resource = AAZObjectType( + serialized_name="privateLinkResource", + ) + _build_schema_sub_resource_read(properties.private_link_resource) + properties.profile = AAZObjectType() + _build_schema_sub_resource_read(properties.profile) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = _schema_nsp_association_read.tags + tags.Element = AAZStrType() + + _schema.id = _schema_nsp_association_read.id + _schema.location = _schema_nsp_association_read.location + _schema.name = _schema_nsp_association_read.name + _schema.properties = _schema_nsp_association_read.properties + _schema.tags = _schema_nsp_association_read.tags + _schema.type = _schema_nsp_association_read.type + + +_schema_sub_resource_read = None + + +def _build_schema_sub_resource_read(_schema): + global _schema_sub_resource_read + if _schema_sub_resource_read is not None: + _schema.id = _schema_sub_resource_read.id + return + + _schema_sub_resource_read = AAZObjectType() + + sub_resource_read = _schema_sub_resource_read + sub_resource_read.id = AAZStrType() + + _schema.id = _schema_sub_resource_read.id + + +__all__ = ["Update"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_wait.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_wait.py new file mode 100644 index 00000000000..d613ec12b7b --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/association/_wait.py @@ -0,0 +1,205 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter association 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.network/networksecurityperimeters/{}/resourceassociations/{}", "2021-02-01-preview"], + ] + } + + 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.association_name = AAZStrArg( + options=["-n", "--name", "--association-name"], + help="The name of the NSP association.", + required=True, + id_part="child_name_1", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAssociationsGet(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class NspAssociationsGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}", + **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( + "associationName", self.ctx.args.association_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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", "2021-02-01-preview", + 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() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.access_mode = AAZStrType( + serialized_name="accessMode", + ) + properties.has_provisioning_issues = AAZStrType( + serialized_name="hasProvisioningIssues", + flags={"read_only": True}, + ) + properties.private_link_resource = AAZObjectType( + serialized_name="privateLinkResource", + ) + _build_schema_sub_resource_read(properties.private_link_resource) + properties.profile = AAZObjectType() + _build_schema_sub_resource_read(properties.profile) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +_schema_sub_resource_read = None + + +def _build_schema_sub_resource_read(_schema): + global _schema_sub_resource_read + if _schema_sub_resource_read is not None: + _schema.id = _schema_sub_resource_read.id + return + + _schema_sub_resource_read = AAZObjectType() + + sub_resource_read = _schema_sub_resource_read + sub_resource_read.id = AAZStrType() + + _schema.id = _schema_sub_resource_read.id + + +__all__ = ["Wait"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__cmd_group.py new file mode 100644 index 00000000000..f0bac8a9c10 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__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 perimeter onboarded-resources", +) +class __CMDGroup(AAZCommandGroup): + """Manage resources onboarded to NSP + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/_list.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/_list.py new file mode 100644 index 00000000000..02ef841144d --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/onboarded_resources/_list.py @@ -0,0 +1,181 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter onboarded-resources list", +) +class List(AAZCommand): + """Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter. + + :example: List NSP onboarded resources + az network perimeter onboarded-resources list -l northcentralus + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.network/locations/{}/perimeterassociableresourcetypes", "2021-02-01-preview"], + ] + } + + 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.location = AAZResourceLocationArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.PerimeterAssociableResourceTypesList(ctx=self.ctx)() + + 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 PerimeterAssociableResourceTypesList(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.Network/locations/{location}/perimeterAssociableResourceTypes", + **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( + "location", self.ctx.args.location, + 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", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.display_name = AAZStrType( + serialized_name="displayName", + flags={"read_only": True}, + ) + properties.public_dns_zones = AAZListType( + serialized_name="publicDnsZones", + flags={"read_only": True}, + ) + properties.resource_type = AAZStrType( + serialized_name="resourceType", + flags={"read_only": True}, + ) + + public_dns_zones = cls._schema_on_200.value.Element.properties.public_dns_zones + public_dns_zones.Element = AAZStrType( + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["List"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__cmd_group.py new file mode 100644 index 00000000000..00ed54a28fd --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__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 perimeter profile", +) +class __CMDGroup(AAZCommandGroup): + """Manage Network Profiles under an NSP + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__init__.py new file mode 100644 index 00000000000..efc3964e3fb --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_create.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_create.py new file mode 100644 index 00000000000..5cbae89ea8e --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_create.py @@ -0,0 +1,218 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile create", +) +class Create(AAZCommand): + """Creates or updates a network profile. + + :example: Create NSP Profile + az network perimeter profile create -n MyProfile --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["-n", "--name", "--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.NspProfilesCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspProfilesCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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") + _builder.set_prop("name", AAZStrType, ".profile_name") + _builder.set_prop("tags", AAZDictType, ".tags") + + tags = _builder.get(".tags") + if tags is not None: + tags.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() + _schema_on_200_201.name = AAZStrType() + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.access_rules_version = AAZStrType( + serialized_name="accessRulesVersion", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +__all__ = ["Create"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_delete.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_delete.py new file mode 100644 index 00000000000..42252031fd5 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_delete.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 * + + +@register_command( + "network perimeter profile delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Deletes an NSP profile. + + :example: Delete NSP Profile + az network perimeter profile delete -n MyProfile --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}", "2021-02-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["-n", "--name", "--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspProfilesDelete(ctx=self.ctx)() + + class NspProfilesDelete(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) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +__all__ = ["Delete"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_list.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_list.py new file mode 100644 index 00000000000..6eac209f903 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_list.py @@ -0,0 +1,195 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile list", +) +class List(AAZCommand): + """Lists the NSP profiles in the specified network security perimeter. + + :example: List NSP Profiles inside a Perimeter + az network perimeter profile list --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.skip_token = AAZStrArg( + options=["--skip-token"], + help="SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="An optional query parameter which specifies the maximum number of records to be returned by the server.", + fmt=AAZIntArgFormat( + maximum=20, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.NspProfilesList(ctx=self.ctx)() + + 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 NspProfilesList(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_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( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.access_rules_version = AAZStrType( + serialized_name="accessRulesVersion", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["List"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_show.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_show.py new file mode 100644 index 00000000000..ef1280d963b --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/_show.py @@ -0,0 +1,179 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile show", +) +class Show(AAZCommand): + """Gets the specified NSP profile. + + :example: Get NSP Profile + az network perimeter profile show --perimeter-name MyPerimeter -g MyResourceGroup -n MyProfile + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["-n", "--name", "--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspProfilesGet(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspProfilesGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.access_rules_version = AAZStrType( + serialized_name="accessRulesVersion", + flags={"read_only": True}, + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["Show"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__cmd_group.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__cmd_group.py new file mode 100644 index 00000000000..c3baa473d0e --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__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 perimeter profile access-rule", +) +class __CMDGroup(AAZCommandGroup): + """Manage Access Rules of a Profile inside an NSP + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__init__.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__init__.py new file mode 100644 index 00000000000..c401f439385 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/__init__.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_create.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_create.py new file mode 100644 index 00000000000..2564ac28834 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_create.py @@ -0,0 +1,360 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile access-rule create", +) +class Create(AAZCommand): + """Creates or updates a network access rule. + + :example: Create IP based access rule + az network perimeter profile access-rule create -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup --address-prefixes "[10.10.0.0/16]" + + :example: Create NSP based access rule + az network perimeter profile access-rule create -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup --nsp "[{id:}]" + + :example: Create FQDN based access rule + az network perimeter profile access-rule create -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup --fqdn "['www.abc.com', 'www.google.com']" --direction "Outbound" + + :example: Create Subscription based access rule + az network perimeter profile access-rule create -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup --subscriptions [0].id="" [1].id="" + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}/accessrules/{}", "2021-02-01-preview"], + ] + } + + 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.access_rule_name = AAZStrArg( + options=["-n", "--name", "--access-rule-name"], + help="The name of the NSP access rule.", + required=True, + id_part="child_name_2", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location.", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.address_prefixes = AAZListArg( + options=["--address-prefixes"], + arg_group="Properties", + help="Inbound address prefixes (IPv4/IPv6)", + ) + _args_schema.direction = AAZStrArg( + options=["--direction"], + arg_group="Properties", + help="Direction that specifies whether the access rules is inbound/outbound.", + enum={"Inbound": "Inbound", "Outbound": "Outbound"}, + ) + _args_schema.fqdn = AAZListArg( + options=["--fqdn"], + arg_group="Properties", + help="Outbound rules fully qualified domain name format.", + ) + _args_schema.nsp = AAZListArg( + options=["--nsp"], + arg_group="Properties", + help="Inbound rule specified by the perimeter id.", + ) + _args_schema.subscriptions = AAZListArg( + options=["--subscriptions"], + arg_group="Properties", + help="Subscription id in the ARM id format.", + ) + + address_prefixes = cls._args_schema.address_prefixes + address_prefixes.Element = AAZStrArg() + + fqdn = cls._args_schema.fqdn + fqdn.Element = AAZStrArg() + + nsp = cls._args_schema.nsp + nsp.Element = AAZObjectArg() + + _element = cls._args_schema.nsp.Element + _element.id = AAZStrArg( + options=["id"], + help="NSP id in the ARM id format.", + ) + + subscriptions = cls._args_schema.subscriptions + subscriptions.Element = AAZObjectArg() + + _element = cls._args_schema.subscriptions.Element + _element.id = AAZStrArg( + options=["id"], + help="Subscription ID in the ARM ID fromat.", + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAccessRulesCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAccessRulesCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}", + **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( + "accessRuleName", self.ctx.args.access_rule_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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") + _builder.set_prop("name", AAZStrType, ".access_rule_name") + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("addressPrefixes", AAZListType, ".address_prefixes") + properties.set_prop("direction", AAZStrType, ".direction") + properties.set_prop("fullyQualifiedDomainNames", AAZListType, ".fqdn") + properties.set_prop("networkSecurityPerimeters", AAZListType, ".nsp") + properties.set_prop("subscriptions", AAZListType, ".subscriptions") + + address_prefixes = _builder.get(".properties.addressPrefixes") + if address_prefixes is not None: + address_prefixes.set_elements(AAZStrType, ".") + + fully_qualified_domain_names = _builder.get(".properties.fullyQualifiedDomainNames") + if fully_qualified_domain_names is not None: + fully_qualified_domain_names.set_elements(AAZStrType, ".") + + network_security_perimeters = _builder.get(".properties.networkSecurityPerimeters") + if network_security_perimeters is not None: + network_security_perimeters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkSecurityPerimeters[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id") + + subscriptions = _builder.get(".properties.subscriptions") + if subscriptions is not None: + subscriptions.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.subscriptions[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id") + + tags = _builder.get(".tags") + if tags is not None: + tags.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() + _schema_on_200_201.name = AAZStrType() + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.address_prefixes = AAZListType( + serialized_name="addressPrefixes", + ) + properties.direction = AAZStrType() + properties.fully_qualified_domain_names = AAZListType( + serialized_name="fullyQualifiedDomainNames", + ) + properties.network_security_perimeters = AAZListType( + serialized_name="networkSecurityPerimeters", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.subscriptions = AAZListType() + + address_prefixes = cls._schema_on_200_201.properties.address_prefixes + address_prefixes.Element = AAZStrType() + + fully_qualified_domain_names = cls._schema_on_200_201.properties.fully_qualified_domain_names + fully_qualified_domain_names.Element = AAZStrType() + + network_security_perimeters = cls._schema_on_200_201.properties.network_security_perimeters + network_security_perimeters.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.network_security_perimeters.Element + _element.id = AAZStrType() + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + + subscriptions = cls._schema_on_200_201.properties.subscriptions + subscriptions.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.subscriptions.Element + _element.id = AAZStrType() + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +__all__ = ["Create"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_delete.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_delete.py new file mode 100644 index 00000000000..aef785134ed --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_delete.py @@ -0,0 +1,145 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile access-rule delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Deletes an NSP access rule. + + :example: Delete NSP access rule + az network perimeter profile access-rule delete -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}/accessrules/{}", "2021-02-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return 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.access_rule_name = AAZStrArg( + options=["-n", "--name", "--access-rule-name"], + help="The name of the NSP access rule.", + required=True, + id_part="child_name_2", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAccessRulesDelete(ctx=self.ctx)() + + class NspAccessRulesDelete(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) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}", + **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( + "accessRuleName", self.ctx.args.access_rule_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +__all__ = ["Delete"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_list.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_list.py new file mode 100644 index 00000000000..3265f7d8c26 --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_list.py @@ -0,0 +1,240 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile access-rule list", +) +class List(AAZCommand): + """Lists the NSP access rules in the specified NSP profile. + + :example: List access rules inside a Profile + az network perimeter profile access-rule list --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}/accessrules", "2021-02-01-preview"], + ] + } + + 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.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + ) + _args_schema.profile_name = AAZStrArg( + options=["--profile-name"], + help="The name of the NSP profile.", + required=True, + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.skip_token = AAZStrArg( + options=["--skip-token"], + help="SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls.", + ) + _args_schema.top = AAZIntArg( + options=["--top"], + help="An optional query parameter which specifies the maximum number of records to be returned by the server.", + fmt=AAZIntArgFormat( + maximum=20, + minimum=1, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAccessRulesList(ctx=self.ctx)() + + 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 NspAccessRulesList(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules", + **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( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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( + "$skipToken", self.ctx.args.skip_token, + ), + **self.serialize_query_param( + "$top", self.ctx.args.top, + ), + **self.serialize_query_param( + "api-version", "2021-02-01-preview", + 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() + + 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() + _element.name = AAZStrType() + _element.properties = AAZObjectType() + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.address_prefixes = AAZListType( + serialized_name="addressPrefixes", + ) + properties.direction = AAZStrType() + properties.fully_qualified_domain_names = AAZListType( + serialized_name="fullyQualifiedDomainNames", + ) + properties.network_security_perimeters = AAZListType( + serialized_name="networkSecurityPerimeters", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.subscriptions = AAZListType() + + address_prefixes = cls._schema_on_200.value.Element.properties.address_prefixes + address_prefixes.Element = AAZStrType() + + fully_qualified_domain_names = cls._schema_on_200.value.Element.properties.fully_qualified_domain_names + fully_qualified_domain_names.Element = AAZStrType() + + network_security_perimeters = cls._schema_on_200.value.Element.properties.network_security_perimeters + network_security_perimeters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.network_security_perimeters.Element + _element.id = AAZStrType() + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + + subscriptions = cls._schema_on_200.value.Element.properties.subscriptions + subscriptions.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.subscriptions.Element + _element.id = AAZStrType() + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["List"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_show.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_show.py new file mode 100644 index 00000000000..b0951c8878c --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_show.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile access-rule show", +) +class Show(AAZCommand): + """Gets the specified NSP access rule by name. + + :example: Get NSP access rule + az network perimeter profile access-rule show -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}/accessrules/{}", "2021-02-01-preview"], + ] + } + + 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.access_rule_name = AAZStrArg( + options=["-n", "--name", "--access-rule-name"], + help="The name of the NSP access rule.", + required=True, + id_part="child_name_2", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAccessRulesGet(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAccessRulesGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}", + **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( + "accessRuleName", self.ctx.args.access_rule_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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() + _schema_on_200.name = AAZStrType() + _schema_on_200.properties = AAZObjectType() + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.address_prefixes = AAZListType( + serialized_name="addressPrefixes", + ) + properties.direction = AAZStrType() + properties.fully_qualified_domain_names = AAZListType( + serialized_name="fullyQualifiedDomainNames", + ) + properties.network_security_perimeters = AAZListType( + serialized_name="networkSecurityPerimeters", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.subscriptions = AAZListType() + + address_prefixes = cls._schema_on_200.properties.address_prefixes + address_prefixes.Element = AAZStrType() + + fully_qualified_domain_names = cls._schema_on_200.properties.fully_qualified_domain_names + fully_qualified_domain_names.Element = AAZStrType() + + network_security_perimeters = cls._schema_on_200.properties.network_security_perimeters + network_security_perimeters.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.network_security_perimeters.Element + _element.id = AAZStrType() + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + + subscriptions = cls._schema_on_200.properties.subscriptions + subscriptions.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.subscriptions.Element + _element.id = AAZStrType() + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +__all__ = ["Show"] diff --git a/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_update.py b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_update.py new file mode 100644 index 00000000000..63bba704a8b --- /dev/null +++ b/src/nsp/azext_nsp/aaz/latest/network/perimeter/profile/access_rule/_update.py @@ -0,0 +1,512 @@ +# -------------------------------------------------------------------------------------------- +# 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 perimeter profile access-rule update", +) +class Update(AAZCommand): + """Creates or updates a network access rule. + + :example: Update access rule + az network perimeter profile access-rule update -n MyAccessRule --profile-name MyProfile --perimeter-name MyPerimeter -g MyResourceGroup --address-prefixes "[10.10.0.0/16]" + """ + + _aaz_info = { + "version": "2021-02-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/networksecurityperimeters/{}/profiles/{}/accessrules/{}", "2021-02-01-preview"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + 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.access_rule_name = AAZStrArg( + options=["-n", "--name", "--access-rule-name"], + help="The name of the NSP access rule.", + required=True, + id_part="child_name_2", + ) + _args_schema.perimeter_name = AAZStrArg( + options=["--perimeter-name"], + help="The name of the network security perimeter.", + required=True, + id_part="name", + ) + _args_schema.profile_name = AAZStrArg( + options=["--profile-name"], + help="The name of the NSP profile.", + required=True, + id_part="child_name_1", + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Parameters" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="Parameters", + help="Resource location.", + nullable=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="Parameters", + help="Resource tags.", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.address_prefixes = AAZListArg( + options=["--address-prefixes"], + arg_group="Properties", + help="Inbound address prefixes (IPv4/IPv6)", + nullable=True, + ) + _args_schema.direction = AAZStrArg( + options=["--direction"], + arg_group="Properties", + help="Direction that specifies whether the access rules is inbound/outbound.", + nullable=True, + enum={"Inbound": "Inbound", "Outbound": "Outbound"}, + ) + _args_schema.fqdn = AAZListArg( + options=["--fqdn"], + arg_group="Properties", + help="Outbound rules fully qualified domain name format.", + nullable=True, + ) + _args_schema.nsp = AAZListArg( + options=["--nsp"], + arg_group="Properties", + help="Inbound rule specified by the perimeter id.", + nullable=True, + ) + _args_schema.subscriptions = AAZListArg( + options=["--subscriptions"], + arg_group="Properties", + help="Subscription id in the ARM id format.", + nullable=True, + ) + + address_prefixes = cls._args_schema.address_prefixes + address_prefixes.Element = AAZStrArg( + nullable=True, + ) + + fqdn = cls._args_schema.fqdn + fqdn.Element = AAZStrArg( + nullable=True, + ) + + nsp = cls._args_schema.nsp + nsp.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.nsp.Element + _element.id = AAZStrArg( + options=["id"], + help="NSP id in the ARM id format.", + nullable=True, + ) + + subscriptions = cls._args_schema.subscriptions + subscriptions.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.subscriptions.Element + _element.id = AAZStrArg( + options=["id"], + help="Subscription ID in the ARM ID fromat.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.NspAccessRulesGet(ctx=self.ctx)() + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.NspAccessRulesCreateOrUpdate(ctx=self.ctx)() + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class NspAccessRulesGet(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/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}", + **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( + "accessRuleName", self.ctx.args.access_rule_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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() + _build_schema_nsp_access_rule_read(cls._schema_on_200) + + return cls._schema_on_200 + + class NspAccessRulesCreateOrUpdate(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]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}", + **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( + "accessRuleName", self.ctx.args.access_rule_name, + required=True, + ), + **self.serialize_url_param( + "networkSecurityPerimeterName", self.ctx.args.perimeter_name, + required=True, + ), + **self.serialize_url_param( + "profileName", self.ctx.args.profile_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", "2021-02-01-preview", + 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() + _build_schema_nsp_access_rule_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("location", AAZStrType, ".location") + _builder.set_prop("name", AAZStrType, ".access_rule_name") + _builder.set_prop("properties", AAZObjectType) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("addressPrefixes", AAZListType, ".address_prefixes") + properties.set_prop("direction", AAZStrType, ".direction") + properties.set_prop("fullyQualifiedDomainNames", AAZListType, ".fqdn") + properties.set_prop("networkSecurityPerimeters", AAZListType, ".nsp") + properties.set_prop("subscriptions", AAZListType, ".subscriptions") + + address_prefixes = _builder.get(".properties.addressPrefixes") + if address_prefixes is not None: + address_prefixes.set_elements(AAZStrType, ".") + + fully_qualified_domain_names = _builder.get(".properties.fullyQualifiedDomainNames") + if fully_qualified_domain_names is not None: + fully_qualified_domain_names.set_elements(AAZStrType, ".") + + network_security_perimeters = _builder.get(".properties.networkSecurityPerimeters") + if network_security_perimeters is not None: + network_security_perimeters.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.networkSecurityPerimeters[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id") + + subscriptions = _builder.get(".properties.subscriptions") + if subscriptions is not None: + subscriptions.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.subscriptions[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id") + + tags = _builder.get(".tags") + if tags is not None: + tags.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 + ) + + +_schema_nsp_access_rule_read = None + + +def _build_schema_nsp_access_rule_read(_schema): + global _schema_nsp_access_rule_read + if _schema_nsp_access_rule_read is not None: + _schema.id = _schema_nsp_access_rule_read.id + _schema.location = _schema_nsp_access_rule_read.location + _schema.name = _schema_nsp_access_rule_read.name + _schema.properties = _schema_nsp_access_rule_read.properties + _schema.tags = _schema_nsp_access_rule_read.tags + _schema.type = _schema_nsp_access_rule_read.type + return + + _schema_nsp_access_rule_read = AAZObjectType() + + nsp_access_rule_read = _schema_nsp_access_rule_read + nsp_access_rule_read.id = AAZStrType( + flags={"read_only": True}, + ) + nsp_access_rule_read.location = AAZStrType() + nsp_access_rule_read.name = AAZStrType() + nsp_access_rule_read.properties = AAZObjectType() + nsp_access_rule_read.tags = AAZDictType() + nsp_access_rule_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_nsp_access_rule_read.properties + properties.address_prefixes = AAZListType( + serialized_name="addressPrefixes", + ) + properties.direction = AAZStrType() + properties.fully_qualified_domain_names = AAZListType( + serialized_name="fullyQualifiedDomainNames", + ) + properties.network_security_perimeters = AAZListType( + serialized_name="networkSecurityPerimeters", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.subscriptions = AAZListType() + + address_prefixes = _schema_nsp_access_rule_read.properties.address_prefixes + address_prefixes.Element = AAZStrType() + + fully_qualified_domain_names = _schema_nsp_access_rule_read.properties.fully_qualified_domain_names + fully_qualified_domain_names.Element = AAZStrType() + + network_security_perimeters = _schema_nsp_access_rule_read.properties.network_security_perimeters + network_security_perimeters.Element = AAZObjectType() + + _element = _schema_nsp_access_rule_read.properties.network_security_perimeters.Element + _element.id = AAZStrType() + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.perimeter_guid = AAZStrType( + serialized_name="perimeterGuid", + flags={"read_only": True}, + ) + + subscriptions = _schema_nsp_access_rule_read.properties.subscriptions + subscriptions.Element = AAZObjectType() + + _element = _schema_nsp_access_rule_read.properties.subscriptions.Element + _element.id = AAZStrType() + + tags = _schema_nsp_access_rule_read.tags + tags.Element = AAZStrType() + + _schema.id = _schema_nsp_access_rule_read.id + _schema.location = _schema_nsp_access_rule_read.location + _schema.name = _schema_nsp_access_rule_read.name + _schema.properties = _schema_nsp_access_rule_read.properties + _schema.tags = _schema_nsp_access_rule_read.tags + _schema.type = _schema_nsp_access_rule_read.type + + +__all__ = ["Update"] diff --git a/src/nsp/azext_nsp/azext_metadata.json b/src/nsp/azext_nsp/azext_metadata.json new file mode 100644 index 00000000000..ade6d0c3e08 --- /dev/null +++ b/src/nsp/azext_nsp/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.38.0" +} \ No newline at end of file diff --git a/src/nsp/azext_nsp/commands.py b/src/nsp/azext_nsp/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/nsp/azext_nsp/commands.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/nsp/azext_nsp/custom.py b/src/nsp/azext_nsp/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/nsp/azext_nsp/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/nsp/azext_nsp/tests/__init__.py b/src/nsp/azext_nsp/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/nsp/azext_nsp/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/nsp/azext_nsp/tests/latest/__init__.py b/src/nsp/azext_nsp/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_crud.yaml b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_crud.yaml new file mode 100644 index 00000000000..a37ed87f8e7 --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_crud.yaml @@ -0,0 +1,567 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "name": "TestNetworkSecurityPerimeter"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"dff3bcf8-f8ff-4ef2-981a-2cb3fbc866e3","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '427' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:34 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001","name":"test_nsp_accessrule_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '343' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:35 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspProfile"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + Content-Length: + - '53' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}' + headers: + cache-control: + - no-cache + content-length: + - '396' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:37 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --fqdn --direction + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001","name":"test_nsp_accessrule_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '343' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAccessRule", "properties": + {"direction": "Outbound", "fullyQualifiedDomainNames": ["www.abc.com", "www.google.com"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + Content-Length: + - '161' + Content-Type: + - application/json + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --fqdn --direction + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com","www.google.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '546' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule show + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com","www.google.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '546' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:44 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule update + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --fqdn --direction + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001","name":"test_nsp_accessrule_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '343' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule update + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --fqdn --direction + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com","www.google.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '546' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:45 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAccessRule", "properties": + {"addressPrefixes": [], "direction": "Outbound", "fullyQualifiedDomainNames": + ["www.abc.com"], "networkSecurityPerimeters": [], "subscriptions": []}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule update + Connection: + - keep-alive + Content-Length: + - '220' + Content-Type: + - application/json + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --fqdn --direction + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '529' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:46 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule show + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '529' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:48 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule list + Connection: + - keep-alive + ParameterSetName: + - --perimeter-name --profile-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules?api-version=2021-02-01-preview + response: + body: + string: '{"nextLink":"","value":[{"name":"TestNspAccessRule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Outbound","addressPrefixes":[],"fullyQualifiedDomainNames":["www.abc.com"],"subscriptions":[],"networkSecurityPerimeters":[]}}]}' + headers: + cache-control: + - no-cache + content-length: + - '555' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:50 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --name --perimeter-name --profile-name --resource-group --yes + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule?api-version=2021-02-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 17 Nov 2022 03:27:55 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_inbound.yaml b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_inbound.yaml new file mode 100644 index 00000000000..f7ab78b6892 --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_accessrule_inbound.yaml @@ -0,0 +1,485 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "name": "TestNetworkSecurityPerimeter"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"b0699211-c569-4331-8e23-d8b1c7827e7e","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '430' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:36 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_inbound000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001","name":"test_nsp_accessrule_inbound000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '349' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:36 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspProfile"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + Content-Length: + - '53' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}' + headers: + cache-control: + - no-cache + content-length: + - '399' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --address-prefixes + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_inbound000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001","name":"test_nsp_accessrule_inbound000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '349' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:41 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAccessRule_ip", "properties": + {"addressPrefixes": ["10.10.0.0/16"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + Content-Length: + - '112' + Content-Type: + - application/json + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --address-prefixes + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_ip?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule_ip","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_ip","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Inbound","addressPrefixes":["10.10.0.0/16"],"fullyQualifiedDomainNames":[],"subscriptions":[],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '538' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:45 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --subscriptions + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_inbound000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001","name":"test_nsp_accessrule_inbound000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '349' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAccessRule_subscription", "properties": + {"subscriptions": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000"}]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + Content-Length: + - '167' + Content-Type: + - application/json + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --subscriptions + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_subscription?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule_subscription","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_subscription","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Inbound","addressPrefixes":[],"fullyQualifiedDomainNames":[],"subscriptions":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000"}],"networkSecurityPerimeters":[]}}' + headers: + cache-control: + - no-cache + content-length: + - '604' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:48 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "nsp_for_rule"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '51' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule?api-version=2021-02-01-preview + response: + body: + string: '{"name":"nsp_for_rule","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"34fe1e07-6a99-4d34-afee-653690b0de95","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '398' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:00 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --nsp + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_accessrule_inbound000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001","name":"test_nsp_accessrule_inbound000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '349' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAccessRule_nsp", "properties": + {"networkSecurityPerimeters": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule"}]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile access-rule create + Connection: + - keep-alive + Content-Length: + - '286' + Content-Type: + - application/json + ParameterSetName: + - --name --profile-name --perimeter-name --resource-group --nsp + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_nsp?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAccessRule_nsp","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile/accessRules/TestNspAccessRule_nsp","type":"Microsoft.Network/networkSecurityPerimeters/profiles/accessRules","properties":{"provisioningState":"Succeeded","direction":"Inbound","addressPrefixes":[],"fullyQualifiedDomainNames":[],"subscriptions":[],"networkSecurityPerimeters":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_accessrule_inbound000001/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule","perimeterGuid":"34fe1e07-6a99-4d34-afee-653690b0de95","location":"eastus2euap"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '782' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:03 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +version: 1 diff --git a/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_association_crud.yaml b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_association_crud.yaml new file mode 100644 index 00000000000..6bf7001d67a --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_association_crud.yaml @@ -0,0 +1,965 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "name": "TestNetworkSecurityPerimeter"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"27e1cf3e-c620-4a77-8e15-c3c712cedf60","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '428' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:35 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_association_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001","name":"test_nsp_association_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:35 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspProfile"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + Content-Length: + - '53' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}' + headers: + cache-control: + - no-cache + content-length: + - '397' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:38 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault create + Connection: + - keep-alive + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5?api-version=2022-07-01 + response: + body: + string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.KeyVault/vaults/kvnspclitest5'' + under resource group ''test_nsp_association_crud000001'' was not found. For + more details please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '242' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault create + Connection: + - keep-alive + ParameterSetName: + - --name -l --resource-group + User-Agent: + - python/3.10.5 (Windows-10-10.0.22621-SP0) AZURECLI/2.42.0 + method: GET + uri: https://graph.microsoft.com/v1.0/me + response: + body: + string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity","businessPhones":[],"displayName":"Nikhil + Saxena","givenName":"Nikhil","jobTitle":"SOFTWARE ENGINEER","mail":"nikhilsaxena@microsoft.com","mobilePhone":null,"officeLocation":"BENGALURU + LUXOR-MIRPL/Mobile","preferredLanguage":null,"surname":"Saxena","userPrincipalName":"nikhilsaxena@microsoft.com","id":"d50cfdce-f74f-4b75-9ea4-dd65c07770fd"}' + headers: + cache-control: + - no-cache + content-length: + - '419' + content-type: + - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:40 GMT + odata-version: + - '4.0' + request-id: + - 4bc621ad-27cf-4c03-8d6c-f8d489e89253 + strict-transport-security: + - max-age=31536000 + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-ms-ags-diagnostic: + - '{"ServerInfo":{"DataCenter":"South India","Slice":"E","Ring":"2","ScaleUnit":"000","RoleInstance":"MA1PEPF000012F3"}}' + x-ms-resource-unit: + - '1' + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "properties": {"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "sku": {"family": "A", "name": "standard"}, "accessPolicies": [{"tenantId": + "72f988bf-86f1-41af-91ab-2d7cd011db47", "objectId": "d50cfdce-f74f-4b75-9ea4-dd65c07770fd", + "permissions": {"keys": ["all"], "secrets": ["all"], "certificates": ["all"], + "storage": ["all"]}}], "enableSoftDelete": true, "softDeleteRetentionInDays": + 90, "networkAcls": {"bypass": "AzureServices", "defaultAction": "Allow"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault create + Connection: + - keep-alive + Content-Length: + - '493' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5?api-version=2022-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5","name":"kvnspclitest5","type":"Microsoft.KeyVault/vaults","location":"eastus2euap","tags":{},"systemData":{"createdBy":"nikhilsaxena@microsoft.com","createdByType":"User","createdAt":"2022-11-17T03:27:46.183Z","lastModifiedBy":"nikhilsaxena@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-11-17T03:27:46.183Z"},"properties":{"sku":{"family":"A","name":"standard"},"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","accessPolicies":[{"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","objectId":"d50cfdce-f74f-4b75-9ea4-dd65c07770fd","permissions":{"keys":["all"],"secrets":["all"],"certificates":["all"],"storage":["all"]}}],"enabledForDeployment":false,"enableSoftDelete":true,"softDeleteRetentionInDays":90,"vaultUri":"https://kvnspclitest5.vault.azure.net","provisioningState":"RegisteringDns","publicNetworkAccess":"Enabled"}}' + headers: + cache-control: + - no-cache + content-length: + - '1005' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:49 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-keyvault-service-version: + - 1.5.564.0 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault create + Connection: + - keep-alive + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5?api-version=2022-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5","name":"kvnspclitest5","type":"Microsoft.KeyVault/vaults","location":"eastus2euap","tags":{},"systemData":{"createdBy":"nikhilsaxena@microsoft.com","createdByType":"User","createdAt":"2022-11-17T03:27:46.183Z","lastModifiedBy":"nikhilsaxena@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-11-17T03:27:46.183Z"},"properties":{"sku":{"family":"A","name":"standard"},"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","accessPolicies":[{"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","objectId":"d50cfdce-f74f-4b75-9ea4-dd65c07770fd","permissions":{"keys":["all"],"secrets":["all"],"certificates":["all"],"storage":["all"]}}],"enabledForDeployment":false,"enableSoftDelete":true,"softDeleteRetentionInDays":90,"vaultUri":"https://kvnspclitest5.vault.azure.net/","provisioningState":"Succeeded","publicNetworkAccess":"Enabled"}}' + headers: + cache-control: + - no-cache + content-length: + - '1001' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:19 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-keyvault-service-version: + - 1.5.564.0 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association create + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group --access-mode --private-link-resource + --profile + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_association_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001","name":"test_nsp_association_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAssociation", "properties": + {"accessMode": "Learning", "privateLinkResource": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"}, + "profile": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association create + Connection: + - keep-alive + Content-Length: + - '510' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group --access-mode --private-link-resource + --profile + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Learning","provisioningState":"Accepted","hasProvisioningIssues":"no"}}' + headers: + cache-control: + - no-cache + content-length: + - '836' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:28 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association show + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Learning","provisioningState":"Succeeded","hasProvisioningIssues":"no"}}' + headers: + cache-control: + - no-cache + content-length: + - '837' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:29 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association update + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group --access-mode --private-link-resource + --profile + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_association_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001","name":"test_nsp_association_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:27:17Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association update + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group --access-mode --private-link-resource + --profile + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Learning","provisioningState":"Succeeded","hasProvisioningIssues":"no"}}' + headers: + cache-control: + - no-cache + content-length: + - '837' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:30 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspAssociation", "properties": + {"accessMode": "Enforced", "privateLinkResource": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"}, + "profile": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association update + Connection: + - keep-alive + Content-Length: + - '510' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group --access-mode --private-link-resource + --profile + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Enforced","provisioningState":"Accepted","hasProvisioningIssues":"no"}}' + headers: + cache-control: + - no-cache + content-length: + - '836' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:31 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association show + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Enforced","provisioningState":"Succeeded","hasProvisioningIssues":"no"}}' + headers: + cache-control: + - no-cache + content-length: + - '837' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:34 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association list + Connection: + - keep-alive + ParameterSetName: + - --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations?api-version=2021-02-01-preview + response: + body: + string: '{"nextLink":"","value":[{"name":"TestNspAssociation","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation","type":"Microsoft.Network/networkSecurityPerimeters/resourceAssociations","properties":{"privateLinkResource":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5"},"profile":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile"},"accessMode":"Enforced","provisioningState":"Succeeded","hasProvisioningIssues":"no"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '863' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:37 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --name --perimeter-name --resource-group --yes + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + date: + - Thu, 17 Nov 2022 03:28:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter association show + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation?api-version=2021-02-01-preview + response: + body: + string: '{"error":{"message":"Resource [/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/resourceAssociations/TestNspAssociation] + does not exist or has been deleted","code":"NotFound"}}' + headers: + cache-control: + - no-cache + content-length: + - '309' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:41 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 404 + message: Not Found +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --name --resource-group --no-wait + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5?api-version=2022-07-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 17 Nov 2022 03:28:52 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-keyvault-service-version: + - 1.5.564.0 + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault purge + Connection: + - keep-alive + ParameterSetName: + - --name -l --no-wait + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/eastus2euap/deletedVaults/kvnspclitest5?api-version=2022-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/eastus2euap/deletedVaults/kvnspclitest5","name":"kvnspclitest5","type":"Microsoft.KeyVault/deletedVaults","properties":{"vaultId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_association_crud000001/providers/Microsoft.KeyVault/vaults/kvnspclitest5","location":"eastus2euap","tags":{},"deletionDate":"2022-11-17T03:28:43Z","scheduledPurgeDate":"2023-02-15T03:28:43Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '497' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:54 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-keyvault-service-version: + - 1.5.564.0 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - keyvault purge + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --name -l --no-wait + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-keyvault/10.1.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/eastus2euap/deletedVaults/kvnspclitest5/purge?api-version=2022-07-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 17 Nov 2022 03:28:55 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/eastus2euap/operationResults/VVR8MDYzODA0MjUyNTM3MDAyNjQ0M3w5NkY1ODU0NTYxREI0NDE3OUNCMkM3ODM5OTA4MTBDMg?api-version=2022-07-01 + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-ms-keyvault-service-version: + - 1.5.564.0 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 202 + message: Accepted +version: 1 diff --git a/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_crud.yaml b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_crud.yaml new file mode 100644 index 00000000000..13b5a83640c --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_crud.yaml @@ -0,0 +1,282 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "name": "TestNetworkSecurityPerimeter"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"385bf697-e115-4e47-9cc9-f055297ae4a7","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '416' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:36 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter show + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"385bf697-e115-4e47-9cc9-f055297ae4a7","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '416' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:38 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter list + Connection: + - keep-alive + ParameterSetName: + - --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters?api-version=2021-02-01-preview + response: + body: + string: '{"nextLink":"","value":[{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"385bf697-e115-4e47-9cc9-f055297ae4a7","provisioningState":"Succeeded"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '442' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:40 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g --name --yes + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 17 Nov 2022 03:27:50 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter onboarded-resources list + Connection: + - keep-alive + ParameterSetName: + - -l + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2euap/perimeterAssociableResourceTypes?api-version=2021-02-01-preview + response: + body: + string: '{"type":"","nextLink":"https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2euap/perimeterAssociableResourceTypes?api-version=2021-02-01-preview&firstIndex=10&pageSize=10","value":[{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Sql.servers","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Sql.servers","properties":{"providerNamespace":"Microsoft.Sql","resourceType":"servers","displayName":"Microsoft.Sql/servers","apiVersion":"2021-02-01-preview","publicDnsZones":["database.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Storage.storageAccounts","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Storage.storageAccounts","properties":{"providerNamespace":"Microsoft.Storage","resourceType":"storageAccounts","displayName":"Microsoft.Storage/storageAccounts","apiVersion":"2021-09-01","publicDnsZones":["blob.core.windows.net","table.core.windows.net","queue.core.windows.net","file.core.windows.net","web.core.windows.net","dfs.core.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.EventHub.namespaces","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.EventHub.namespaces","properties":{"providerNamespace":"Microsoft.EventHub","resourceType":"namespaces","displayName":"Microsoft.EventHub/namespaces","apiVersion":"2022-01-01-preview","publicDnsZones":["servicebus.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.CognitiveServices.accounts","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.CognitiveServices.accounts","properties":{"providerNamespace":"Microsoft.CognitiveServices","resourceType":"accounts","displayName":"Microsoft.CognitiveServices/accounts","apiVersion":"2021-10-01","publicDnsZones":["cognitiveservices.azure.com"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Search.searchServices","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Search.searchServices","properties":{"providerNamespace":"Microsoft.Search","resourceType":"searchServices","displayName":"Microsoft.Search/searchServices","apiVersion":"2021-06-06-Preview","publicDnsZones":["search.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Purview.accounts","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Purview.accounts","properties":{"providerNamespace":"Microsoft.Purview","resourceType":"accounts","displayName":"Microsoft.Purview/accounts","apiVersion":"2022-02-01-preview","publicDnsZones":["purview.azure.com"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.ContainerService.managedClusters","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.ContainerService.managedClusters","properties":{"providerNamespace":"Microsoft.ContainerService","resourceType":"managedClusters","displayName":"Microsoft.ContainerService/managedClusters","apiVersion":"2022-03-01","publicDnsZones":["azmk8s.io"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.KeyVault.vaults","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.KeyVault.vaults","properties":{"providerNamespace":"Microsoft.KeyVault","resourceType":"vaults","displayName":"Microsoft.KeyVault/vaults","apiVersion":"2022-02-01-preview","publicDnsZones":["vault.azure.net","vaultcore.azure.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.OperationalInsights.workspaces","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.OperationalInsights.workspaces","properties":{"providerNamespace":"Microsoft.OperationalInsights","resourceType":"workspaces","displayName":"Microsoft.OperationalInsights/workspaces","apiVersion":"2021-10-01","publicDnsZones":["monitor.azure.com","oms.opinsights.azure.com","ods.opinsights.azure.com","agentsvc.azure-automation.net","blob.core.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Insights.dataCollectionEndpoints","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Insights.dataCollectionEndpoints","properties":{"providerNamespace":"Microsoft.Insights","resourceType":"dataCollectionEndpoints","displayName":"Microsoft.Insights/dataCollectionEndpoints","apiVersion":"2021-10-01","publicDnsZones":["monitor.azure.com"]}}]}' + headers: + cache-control: + - no-cache + content-length: + - '4959' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:51 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter onboarded-resources list + Connection: + - keep-alive + ParameterSetName: + - -l + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus2euap/perimeterAssociableResourceTypes?api-version=2021-02-01-preview&firstIndex=10&pageSize=10 + response: + body: + string: '{"type":"","nextLink":"","value":[{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.ServiceBus.namespaces","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.ServiceBus.namespaces","properties":{"providerNamespace":"Microsoft.ServiceBus","resourceType":"namespaces","displayName":"Microsoft.ServiceBus/namespaces","apiVersion":"2022-01-01-preview","publicDnsZones":["servicebus.windows.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Insights.ScheduledQueryRules","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Insights.ScheduledQueryRules","properties":{"providerNamespace":"Microsoft.Insights","resourceType":"ScheduledQueryRules","displayName":"Microsoft.Insights/ScheduledQueryRules","apiVersion":"2021-10-01","publicDnsZones":[]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Insights.actionGroups","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Insights.actionGroups","properties":{"providerNamespace":"Microsoft.Insights","resourceType":"actionGroups","displayName":"Microsoft.Insights/actionGroups","apiVersion":"2021-10-01","publicDnsZones":["azns.azure.com","azns.azure.net","azns.azure.cn","azns.microsofticm.com","azurenotifications.msftcloudes.cn","azurenotifications.msftcloudes.net"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.DocumentDB.databaseAccounts","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.DocumentDB.databaseAccounts","properties":{"providerNamespace":"Microsoft.DocumentDB","resourceType":"databaseAccounts","displayName":"Microsoft.DocumentDB/databaseAccounts","apiVersion":"2022-08-15-preview","publicDnsZones":["documents.azure.com","mongo.cosmos.azure.com","cassandra.cosmos.azure.com","gremlin.cosmos.azure.com","table.cosmos.azure.com"]}},{"type":"Microsoft.Network/PerimeterAssociableResourceTypes","name":"Microsoft.Devices.IotHubs","id":"/subscriptions/{subscriptionId}/providers/Microsoft.Network/PerimeterAssociableResourceTypes/Microsoft.Devices.IotHubs","properties":{"providerNamespace":"Microsoft.Devices","resourceType":"IotHubs","displayName":"Microsoft.Devices/IotHubs","apiVersion":"2021-07-02-preview","publicDnsZones":["servicebus.windows.net","azure-devices.net"]}}]}' + headers: + cache-control: + - no-cache + content-length: + - '2503' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:27:52 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_profile_crud.yaml b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_profile_crud.yaml new file mode 100644 index 00000000000..40dc44f4293 --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/recordings/test_nsp_profile_crud.yaml @@ -0,0 +1,284 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "name": "TestNetworkSecurityPerimeter"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter create + Connection: + - keep-alive + Content-Length: + - '67' + Content-Type: + - application/json + ParameterSetName: + - --name -l --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNetworkSecurityPerimeter","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter","location":"eastus2euap","type":"Microsoft.Network/networkSecurityPerimeters","tags":{},"etag":"","properties":{"perimeterGuid":"b6d13203-58f7-41f9-90ab-28e675155a80","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '424' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:11 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test_nsp_profile_crud000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001","name":"test_nsp_profile_crud000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2euap","tags":{"product":"azurecli","cause":"automation","date":"2022-11-17T03:28:02Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '337' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2euap", "name": "TestNspProfile"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile create + Connection: + - keep-alive + Content-Length: + - '53' + Content-Type: + - application/json + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}' + headers: + cache-control: + - no-cache + content-length: + - '393' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:13 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1197' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile show + Connection: + - keep-alive + ParameterSetName: + - --name --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}' + headers: + cache-control: + - no-cache + content-length: + - '393' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:14 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile list + Connection: + - keep-alive + ParameterSetName: + - --perimeter-name --resource-group + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles?api-version=2021-02-01-preview + response: + body: + string: '{"nextLink":"","value":[{"name":"TestNspProfile","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile","type":"Microsoft.Network/networkSecurityPerimeters/profiles","properties":{"accessRulesVersion":"0","diagnosticSettingsVersion":"0"},"location":"eastus2euap"}]}' + headers: + cache-control: + - no-cache + content-length: + - '419' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Nov 2022 03:28:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - network perimeter profile delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --name --perimeter-name --resource-group --yes + User-Agent: + - AZURECLI/2.42.0 (AAZ) azsdk-python-core/1.24.0 Python/3.10.5 (Windows-10-10.0.22621-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_nsp_profile_crud000001/providers/Microsoft.Network/networkSecurityPerimeters/TestNetworkSecurityPerimeter/profiles/TestNspProfile?api-version=2021-02-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 17 Nov 2022 03:28:19 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/nsp/azext_nsp/tests/latest/test_nsp.py b/src/nsp/azext_nsp/tests/latest/test_nsp.py new file mode 100644 index 00000000000..dfcfedc3936 --- /dev/null +++ b/src/nsp/azext_nsp/tests/latest/test_nsp.py @@ -0,0 +1,144 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * + + +class NspScenario(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='test_nsp_crud', location='eastus2euap') + def test_nsp_crud(self, resource_group): + self.kwargs.update({ + 'name': 'TestNetworkSecurityPerimeter' + }) + + self.cmd('network perimeter create --name {name} -l eastus2euap --resource-group {rg}') + + self.cmd('network perimeter show --resource-group {rg} --name {name}', checks=[ + self.check('name', '{name}') + ]) + + self.cmd('network perimeter list --resource-group {rg}') + + self.cmd('network perimeter delete -g {rg} --name {name} --yes') + + self.cmd('network perimeter onboarded-resources list -l eastus2euap') + + @ResourceGroupPreparer(name_prefix='test_nsp_profile_crud', location='eastus2euap') + def test_nsp_profile_crud(self, resource_group): + self.kwargs.update({ + 'nsp_name': 'TestNetworkSecurityPerimeter', + 'profile_name': 'TestNspProfile' + }) + + self.cmd('network perimeter create --name {nsp_name} -l eastus2euap --resource-group {rg}') + self.cmd('network perimeter profile create --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}') + + self.cmd('network perimeter profile show --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}', checks=[ + self.check('name', '{profile_name}') + ]) + + self.cmd('network perimeter profile list --perimeter-name {nsp_name} --resource-group {rg}') + + self.cmd('network perimeter profile delete --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --yes') + + @ResourceGroupPreparer(name_prefix='test_nsp_accessrule_crud', location='eastus2euap') + def test_nsp_accessrule_crud(self, resource_group): + self.kwargs.update({ + 'nsp_name': 'TestNetworkSecurityPerimeter', + 'profile_name': 'TestNspProfile', + 'accessrule_name': 'TestNspAccessRule' + }) + + self.cmd('network perimeter create --name {nsp_name} -l eastus2euap --resource-group {rg}') + self.cmd('network perimeter profile create --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}') + + self.cmd('az network perimeter profile access-rule create --name {accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --fqdn "[\'www.abc.com\', \'www.google.com\']" --direction "Outbound"') + + self.cmd('az network perimeter profile access-rule show --name {accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}', checks=[ + self.check('properties.fullyQualifiedDomainNames', "[\'www.abc.com\', \'www.google.com\']") + ]) + + self.cmd('az network perimeter profile access-rule update --name {accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --fqdn "[\'www.abc.com\']" --direction "Outbound"') + + self.cmd('az network perimeter profile access-rule show --name {accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}', checks=[ + self.check('properties.fullyQualifiedDomainNames', "[\'www.abc.com\']") + ]) + + self.cmd('network perimeter profile access-rule list --perimeter-name {nsp_name} --profile-name {profile_name} --resource-group {rg}') + + self.cmd('network perimeter profile access-rule delete --name {accessrule_name} --perimeter-name {nsp_name} --profile-name {profile_name} --resource-group {rg} --yes') + + @ResourceGroupPreparer(name_prefix='test_nsp_accessrule_inbound', location='eastus2euap') + def test_nsp_accessrule_inbound(self, resource_group): + self.kwargs.update({ + 'nsp_name': 'TestNetworkSecurityPerimeter', + 'profile_name': 'TestNspProfile', + 'ip_accessrule_name': 'TestNspAccessRule_ip', + 'sub_accessrule_name': 'TestNspAccessRule_subscription', + 'nsp_accessrule_name': 'TestNspAccessRule_nsp', + 'sub': self.get_subscription_id() + }) + + self.cmd('network perimeter create --name {nsp_name} -l eastus2euap --resource-group {rg}') + self.cmd('network perimeter profile create --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}') + + # IP based access rule + self.cmd('az network perimeter profile access-rule create --name {ip_accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --address-prefixes "[10.10.0.0/16]"', checks=[ + self.check('properties.addressPrefixes', "['10.10.0.0/16']") + ]) + + # Subscription based access rule + self.cmd('az network perimeter profile access-rule create --name {sub_accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --subscriptions [0].id="/subscriptions/{sub}"', checks=[ + self.check('properties.subscriptions[0].id', "/subscriptions/{sub}") + ]) + + # NSP based access rule + self.cmd('network perimeter create --name nsp_for_rule -l eastus2euap --resource-group {rg}') + self.cmd('az network perimeter profile access-rule create --name {nsp_accessrule_name} --profile-name {profile_name} --perimeter-name {nsp_name} --resource-group {rg} --nsp [0].id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule"', checks=[ + self.check('properties.networkSecurityPerimeters[0].id', "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/networkSecurityPerimeters/nsp_for_rule") + ]) + + @ResourceGroupPreparer(name_prefix='test_nsp_association_crud', location='eastus2euap') + def test_nsp_association_crud(self, resource_group): + self.kwargs.update({ + 'nsp_name': 'TestNetworkSecurityPerimeter', + 'profile_name': 'TestNspProfile', + 'association_name': 'TestNspAssociation', + 'resource_name': 'kvnspclitest5', + 'sub': self.get_subscription_id() + }) + + self.cmd('network perimeter create --name {nsp_name} -l eastus2euap --resource-group {rg}') + self.cmd('network perimeter profile create --name {profile_name} --perimeter-name {nsp_name} --resource-group {rg}') + + self.cmd('keyvault create --name {resource_name} -l eastus2euap --resource-group {rg}') + + self.cmd('network perimeter association create --name {association_name} --perimeter-name {nsp_name} --resource-group {rg} --access-mode Learning ' + '--private-link-resource id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.KeyVault/vaults/{resource_name}" ' + '--profile id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/networkSecurityPerimeters/{nsp_name}/profiles/{profile_name}"') + + self.cmd('network perimeter association show --name {association_name} --perimeter-name {nsp_name} --resource-group {rg}', checks=[ + self.check('properties.accessMode', 'Learning') + ]) + + self.cmd('network perimeter association update --name {association_name} --perimeter-name {nsp_name} --resource-group {rg} --access-mode Enforced ' + '--private-link-resource id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.KeyVault/vaults/{resource_name}" ' + '--profile id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/networkSecurityPerimeters/{nsp_name}/profiles/{profile_name}"') + + self.cmd('network perimeter association show --name {association_name} --perimeter-name {nsp_name} --resource-group {rg}', checks=[ + self.check('properties.accessMode', 'Enforced') + ]) + + self.cmd('network perimeter association list --perimeter-name {nsp_name} --resource-group {rg}') + + self.cmd('network perimeter association delete --name {association_name} --perimeter-name {nsp_name} --resource-group {rg} --yes') + + self.cmd('network perimeter association show --name {association_name} --perimeter-name {nsp_name} --resource-group {rg}', expect_failure=True) + + self.cmd('keyvault delete --name {resource_name} --resource-group {rg} --no-wait') + self.cmd('keyvault purge --name {resource_name} -l eastus2euap --no-wait') \ No newline at end of file diff --git a/src/nsp/setup.cfg b/src/nsp/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/nsp/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/nsp/setup.py b/src/nsp/setup.py new file mode 100644 index 00000000000..ce54b526922 --- /dev/null +++ b/src/nsp/setup.py @@ -0,0 +1,49 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='nsp', + version=VERSION, + description='Microsoft Azure Command-Line Tools Nsp Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/nsp', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_nsp': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)