From 650e904485bd72eafe4ee1ff45898882d85b293c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 12 Apr 2021 21:17:35 +0000 Subject: [PATCH] CodeGen from PR 13886 in Azure/azure-rest-api-specs change the value of license header (#13886) --- .../__init__.py | 15 +- .../azext_metadata.json | 2 +- .../generated/_client_factory.py | 9 +- .../generated/_help.py | 88 +++-- .../generated/_params.py | 52 ++- .../_version.py => generated/_validators.py} | 10 +- .../generated/action.py | 15 +- .../generated/commands.py | 32 +- .../generated/custom.py | 86 ++-- .../tests/__init__.py | 79 +++- .../tests/latest/example_steps.py | 84 ++++ .../tests/latest/preparers.py | 159 ++++++++ ...test_hardware_security_modules_scenario.py | 76 ++++ .../test_hardwaresecuritymodules_scenario.py | 129 ------ .../hardwaresecuritymodules/__init__.py | 5 +- .../_azure_dedicated_hsm_resource_provider.py | 10 +- .../hardwaresecuritymodules/_configuration.py | 9 +- .../hardwaresecuritymodules/aio/__init__.py | 2 +- ..._azure_dedicated_hsm_resource_provider.py} | 18 +- ...nfiguration_async.py => _configuration.py} | 11 +- .../__init__.py | 4 +- .../_dedicated_hsm_operations.py} | 370 ++++++++++-------- .../aio/operations/_operations.py | 105 +++++ .../models/__init__.py | 12 + ...e_dedicated_hsm_resource_provider_enums.py | 36 +- .../hardwaresecuritymodules/models/_models.py | 135 ++++++- .../models/_models_py3.py | 151 ++++++- .../operations/__init__.py | 2 + .../operations/_dedicated_hsm_operations.py | 360 +++++++++-------- .../operations/_operations.py | 110 ++++++ src/hardware-security-modules/report.md | 153 +++++--- src/hardware-security-modules/setup.cfg | 1 + src/hardware-security-modules/setup.py | 17 +- 33 files changed, 1642 insertions(+), 705 deletions(-) rename src/hardware-security-modules/azext_hardware_security_modules/{vendored_sdks/hardwaresecuritymodules/_version.py => generated/_validators.py} (79%) create mode 100644 src/hardware-security-modules/azext_hardware_security_modules/tests/latest/example_steps.py create mode 100644 src/hardware-security-modules/azext_hardware_security_modules/tests/latest/preparers.py create mode 100644 src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardware_security_modules_scenario.py delete mode 100644 src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardwaresecuritymodules_scenario.py rename src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/{_azure_dedicated_hsm_resource_provider_async.py => _azure_dedicated_hsm_resource_provider.py} (73%) rename src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/{_configuration_async.py => _configuration.py} (86%) rename src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/{operations_async => operations}/__init__.py (81%) rename src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/{operations_async/_dedicated_hsm_operations_async.py => operations/_dedicated_hsm_operations.py} (63%) create mode 100644 src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_operations.py create mode 100644 src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_operations.py diff --git a/src/hardware-security-modules/azext_hardware_security_modules/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/__init__.py index 0645a0a708d..e0e95a9ab5d 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/__init__.py @@ -10,19 +10,22 @@ from azure.cli.core import AzCommandsLoader from azext_hardware_security_modules.generated._help import helps # pylint: disable=unused-import +try: + from azext_hardware_security_modules.manual._help import helps # pylint: disable=reimported +except ImportError: + pass class AzureDedicatedHSMResourceProviderCommandsLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType - from azext_hardware_security_modules.generated._client_factory import cf_hardwaresecuritymodules - hardwaresecuritymodules_custom = CliCommandType( + from azext_hardware_security_modules.generated._client_factory import cf_hardware_security_modules_cl + hardware_security_modules_custom = CliCommandType( operations_tmpl='azext_hardware_security_modules.custom#{}', - client_factory=cf_hardwaresecuritymodules) - super(AzureDedicatedHSMResourceProviderCommandsLoader, - self).__init__( - cli_ctx=cli_ctx, custom_command_type=hardwaresecuritymodules_custom) + client_factory=cf_hardware_security_modules_cl) + parent = super(AzureDedicatedHSMResourceProviderCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=hardware_security_modules_custom) def load_command_table(self, args): from azext_hardware_security_modules.generated.commands import load_command_table diff --git a/src/hardware-security-modules/azext_hardware_security_modules/azext_metadata.json b/src/hardware-security-modules/azext_hardware_security_modules/azext_metadata.json index 13025150393..cfc30c747c7 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/azext_metadata.json +++ b/src/hardware-security-modules/azext_hardware_security_modules/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isExperimental": true, - "azext.minCliCoreVersion": "2.3.1" + "azext.minCliCoreVersion": "2.15.0" } \ No newline at end of file diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/_client_factory.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/_client_factory.py index a8a6ae0de42..a93e026d7a4 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/_client_factory.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/_client_factory.py @@ -9,11 +9,12 @@ # -------------------------------------------------------------------------- -def cf_hardwaresecuritymodules(cli_ctx, *_): +def cf_hardware_security_modules_cl(cli_ctx, *_): from azure.cli.core.commands.client_factory import get_mgmt_service_client - from ..vendored_sdks.hardwaresecuritymodules import AzureDedicatedHSMResourceProvider - return get_mgmt_service_client(cli_ctx, AzureDedicatedHSMResourceProvider) + from azext_hardware_security_modules.vendored_sdks.hardwaresecuritymodules import AzureDedicatedHSMResourceProvider + return get_mgmt_service_client(cli_ctx, + AzureDedicatedHSMResourceProvider) def cf_dedicated_hsm(cli_ctx, *_): - return cf_hardwaresecuritymodules(cli_ctx).dedicated_hsm + return cf_hardware_security_modules_cl(cli_ctx).dedicated_hsm diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/_help.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/_help.py index 894b8f8fb6c..733af91d1fd 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/_help.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/_help.py @@ -12,73 +12,97 @@ from knack.help_files import helps -helps['dedicated-hsm'] = """ +helps['hardware-security-modules dedicated-hsm'] = """ type: group - short-summary: dedicated-hsm to create, update, list, show, and delete HSMs + short-summary: Manage dedicated hsm with hardware security modules """ -helps['dedicated-hsm list'] = """ +helps['hardware-security-modules dedicated-hsm list'] = """ type: command - short-summary: The List operation gets information about the dedicated HSMs associated with the resrouce group. + short-summary: "The List operation gets information about the dedicated hsms associated with the subscription and \ +within the specified resource group. And The List operation gets information about the dedicated HSMs associated with \ +the subscription." examples: - name: List dedicated HSM devices in a resource group text: |- - az dedicated-hsm list -g "hsm-group" -""" - -helps['dedicated-hsm list'] = """ - type: command - short-summary: The List operation gets information about the dedicated HSMs associated with the subscription. - examples: + az hardware-security-modules dedicated-hsm list --resource-group "hsm-group" - name: List dedicated HSM devices in a subscription text: |- - az dedicated-hsm list + az hardware-security-modules dedicated-hsm list """ -helps['dedicated-hsm show'] = """ +helps['hardware-security-modules dedicated-hsm show'] = """ type: command - short-summary: Gets the specified Azure dedicated HSM. + short-summary: "Gets the specified Azure dedicated HSM." examples: - name: Get a dedicated HSM text: |- - az dedicated-hsm show -n "hsm1" -g "hsm-group" + az hardware-security-modules dedicated-hsm show --name "hsm1" --resource-group "hsm-group" """ -helps['dedicated-hsm create'] = """ +helps['hardware-security-modules dedicated-hsm create'] = """ type: command - short-summary: Create a dedicated HSM in the specified subscription. + short-summary: "Create a dedicated HSM in the specified subscription." + parameters: + - name: --subnet + short-summary: "Specifies the identifier of the subnet." + long-summary: | + Usage: --subnet id=XX + + id: The ARM resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/.\ +.. + - name: --network-interfaces + short-summary: "Specifies the list of resource Ids for the network interfaces associated with the dedicated \ +HSM." + long-summary: | + Usage: --network-interfaces private-ip-address=XX + + private-ip-address: Private Ip address of the interface + + Multiple actions can be specified by using more than one --network-interfaces argument. examples: - - name: Create a new dedicated HSM + - name: Create a new or update an existing dedicated HSM text: |- - az dedicated-hsm create -n "hsm1" -l "japanwest" -i private-ip-address="1.0.0.1" \ --s id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/hsm/subnets/hsm" \ ---stamp-id "stamp1" --sku name="SafeNet Luna Network HSM A790" --tags Dept="hsm" Environment="dogfood" -g "hsm-group" + az hardware-security-modules dedicated-hsm create --name "hsm1" --location "westus" \ +--network-interfaces private-ip-address="1.0.0.1" --subnet id="/subscriptions/00000000-0000-0000-0000-000000000000/reso\ +urceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" --stamp-id "stamp01" --tags \ +Dept="hsm" Environment="dogfood" --resource-group "hsm-group" """ -helps['dedicated-hsm update'] = """ +helps['hardware-security-modules dedicated-hsm update'] = """ type: command - short-summary: Update a dedicated HSM in the specified subscription. + short-summary: "Update a dedicated HSM in the specified subscription." examples: - name: Update an existing dedicated HSM text: |- - az dedicated-hsm update -n "hsm1" --tags Dept="hsm" Environment="dogfood" Sl\ -ice="A" -g "hsm-group" + az hardware-security-modules dedicated-hsm update --name "hsm1" --tags Dept="hsm" Environment="dogfood" \ +Slice="A" --resource-group "hsm-group" """ -helps['dedicated-hsm delete'] = """ +helps['hardware-security-modules dedicated-hsm delete'] = """ type: command - short-summary: Deletes the specified Azure Dedicated HSM. + short-summary: "Deletes the specified Azure Dedicated HSM." examples: - name: Delete a dedicated HSM text: |- - az dedicated-hsm delete -n "hsm1" -g "hsm-group" + az hardware-security-modules dedicated-hsm delete --name "hsm1" --resource-group "hsm-group" """ -helps['dedicated-hsm wait'] = """ +helps['hardware-security-modules dedicated-hsm wait'] = """ type: command - short-summary: Waits for operation to complete + short-summary: Place the CLI in a waiting state until a condition of the hardware-security-modules dedicated-hsm \ +is met. examples: - - name: Delete a dedicated HSM + - name: Pause executing next line of CLI script until the hardware-security-modules dedicated-hsm is \ +successfully created. + text: |- + az hardware-security-modules dedicated-hsm wait --name "hsm1" --resource-group "hsm-group" --created + - name: Pause executing next line of CLI script until the hardware-security-modules dedicated-hsm is \ +successfully updated. + text: |- + az hardware-security-modules dedicated-hsm wait --name "hsm1" --resource-group "hsm-group" --updated + - name: Pause executing next line of CLI script until the hardware-security-modules dedicated-hsm is \ +successfully deleted. text: |- - az dedicated-hsm wait --created -g "hsm-group" --name "hsm1" + az hardware-security-modules dedicated-hsm wait --name "hsm1" --resource-group "hsm-group" --deleted """ diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/_params.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/_params.py index c502b974f5e..20bda68a2d5 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/_params.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/_params.py @@ -10,7 +10,6 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from knack.arguments import CLIArgumentType from azure.cli.core.commands.parameters import ( tags_type, resource_group_name_type, @@ -18,48 +17,43 @@ ) from azure.cli.core.commands.validators import get_default_location_from_resource_group from azext_hardware_security_modules.action import ( - AddNetworkProfileSubnet, - AddNetworkProfileNetworkInterfaces + AddSubnet, + AddNetworkInterfaces ) def load_arguments(self, _): - with self.argument_context('dedicated-hsm list') as c: + with self.argument_context('hardware-security-modules dedicated-hsm list') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('top', help='Maximum number of results to return.') + c.argument('top', type=int, help='Maximum number of results to return.') - with self.argument_context('dedicated-hsm show') as c: + with self.argument_context('hardware-security-modules dedicated-hsm show') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('name', options_list=[ - '--name', '-n'], help='The name of the dedicated HSM.') + c.argument('name', type=str, help='The name of the dedicated HSM.', id_part='name') - with self.argument_context('dedicated-hsm create') as c: + with self.argument_context('hardware-security-modules dedicated-hsm create') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('name', options_list=[ - '--name', '-n'], help='Name of the dedicated Hsm') - c.argument('location', arg_type=get_location_type(self.cli_ctx), + c.argument('name', type=str, help='Name of the dedicated Hsm') + c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False, validator=get_default_location_from_resource_group) - c.argument('sku', type=str, - help='The HSM device SKU if a non-standard HSM is wanted (default is: SafeNet Luna Network HSM A790)') - c.argument('zones', nargs='+', - help='The Dedicated Hsm zones.') + c.argument('zones', nargs='+', help='The Dedicated Hsm zones.') c.argument('tags', tags_type) - c.argument( - 'stamp_id', help='This field will be used when RP does not support Availability zones.') - c.argument('network_profile_subnet', arg_group='network profile', options_list=['--subnet', '-s'], action=AddNetworkProfileSubnet, nargs='+', help='Specifies the identifier ' - 'of the subnet. Expected value: id=xx.') - c.argument('network_profile_network_interfaces', options_list=['--network-profile-network-interfaces', '-i'], action=AddNetworkProfileNetworkInterfaces, nargs='+', help='Sp' - 'ecifies a list of ip address from the specfied subnet for the network interfaces associated with the dedicated HSM. Expe' - 'cted value: -i private-ip-address=xx.') + c.argument('stamp_id', type=str, help='This field will be used when RP does not support Availability zones.') + c.argument('subnet', action=AddSubnet, nargs='+', help='Specifies the identifier of the subnet.', + arg_group='Network Profile') + c.argument('network_interfaces', action=AddNetworkInterfaces, nargs='+', help='Specifies the list of resource ' + 'Ids for the network interfaces associated with the dedicated HSM.', arg_group='Network Profile') - with self.argument_context('dedicated-hsm update') as c: + with self.argument_context('hardware-security-modules dedicated-hsm update') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('name', options_list=[ - '--name', '-n'], help='Name of the dedicated HSM') + c.argument('name', type=str, help='Name of the dedicated HSM', id_part='name') c.argument('tags', tags_type) - with self.argument_context('dedicated-hsm delete') as c: + with self.argument_context('hardware-security-modules dedicated-hsm delete') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('name', options_list=[ - '--name', '-n'], help='The name of the dedicated HSM to delete') + c.argument('name', type=str, help='The name of the dedicated HSM to delete', id_part='name') + + with self.argument_context('hardware-security-modules dedicated-hsm wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', type=str, help='The name of the dedicated HSM.', id_part='name') diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_version.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/_validators.py similarity index 79% rename from src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_version.py rename to src/hardware-security-modules/azext_hardware_security_modules/generated/_validators.py index fe0d5a0b414..b33a44c1ebf 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_version.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/_validators.py @@ -1,9 +1,9 @@ -# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- - -VERSION = "2019-05-01T00:00:00.000Z" diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/action.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/action.py index 000b7086e8e..e0f562e345b 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/action.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/action.py @@ -10,14 +10,14 @@ # pylint: disable=protected-access import argparse -from knack.util import CLIError from collections import defaultdict +from knack.util import CLIError -class AddNetworkProfileSubnet(argparse.Action): +class AddSubnet(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) - namespace.network_profile_subnet = action + namespace.subnet = action def get_action(self, values, option_string): # pylint: disable=no-self-use try: @@ -33,13 +33,15 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use v = properties[k] if kl == 'id': d['id'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter subnet. All possible keys are: id'.format(k)) return d -class AddNetworkProfileNetworkInterfaces(argparse._AppendAction): +class AddNetworkInterfaces(argparse._AppendAction): def __call__(self, parser, namespace, values, option_string=None): action = self.get_action(values, option_string) - super(AddNetworkProfileNetworkInterfaces, self).__call__(parser, namespace, action, option_string) + super(AddNetworkInterfaces, self).__call__(parser, namespace, action, option_string) def get_action(self, values, option_string): # pylint: disable=no-self-use try: @@ -55,4 +57,7 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use v = properties[k] if kl == 'private-ip-address': d['private_ip_address'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter network_interfaces. All possible keys ' + 'are: private-ip-address'.format(k)) return d diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/commands.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/commands.py index dc2ebc0879c..be465e6a719 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/commands.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/commands.py @@ -7,6 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals from azure.cli.core.commands import CliCommandType @@ -14,19 +16,19 @@ def load_command_table(self, _): from azext_hardware_security_modules.generated._client_factory import cf_dedicated_hsm - hardwaresecuritymodules_dedicated_hsm = CliCommandType( - operations_tmpl='azext_hardware_security_modules.vendored_sdks.hardwaresecuritymodules.operations._dedicated_hsm_' - 'operations#DedicatedHsmOperations.{}', + hardware_security_modules_dedicated_hsm = CliCommandType( + operations_tmpl='azext_hardware_security_modules.vendored_sdks.hardwaresecuritymodules.operations._dedicated_hs' + 'm_operations#DedicatedHsmOperations.{}', client_factory=cf_dedicated_hsm) - with self.command_group('dedicated-hsm', hardwaresecuritymodules_dedicated_hsm, - client_factory=cf_dedicated_hsm, is_experimental=True) as g: - g.custom_command('list', 'hardwaresecuritymodules_dedicated_hsm_list') - g.custom_show_command( - 'show', 'hardwaresecuritymodules_dedicated_hsm_show') - g.custom_command( - 'create', 'hardwaresecuritymodules_dedicated_hsm_create', supports_no_wait=True) - g.custom_command( - 'update', 'hardwaresecuritymodules_dedicated_hsm_update', supports_no_wait=True) - g.custom_command('delete', 'hardwaresecuritymodules_dedicated_hsm_delete', - supports_no_wait=True, confirmation=True) - g.wait_command('wait') + with self.command_group('hardware-security-modules dedicated-hsm', hardware_security_modules_dedicated_hsm, + client_factory=cf_dedicated_hsm) as g: + g.custom_command('list', 'hardware_security_modules_dedicated_hsm_list') + g.custom_show_command('show', 'hardware_security_modules_dedicated_hsm_show') + g.custom_command('create', 'hardware_security_modules_dedicated_hsm_create', supports_no_wait=True) + g.custom_command('update', 'hardware_security_modules_dedicated_hsm_update', supports_no_wait=True) + g.custom_command('delete', 'hardware_security_modules_dedicated_hsm_delete', supports_no_wait=True, + confirmation=True) + g.custom_wait_command('wait', 'hardware_security_modules_dedicated_hsm_show') + + with self.command_group('hardware-security-modules', is_experimental=True): + pass diff --git a/src/hardware-security-modules/azext_hardware_security_modules/generated/custom.py b/src/hardware-security-modules/azext_hardware_security_modules/generated/custom.py index 46c466c61cd..25355febaca 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/generated/custom.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/generated/custom.py @@ -10,56 +10,68 @@ # pylint: disable=too-many-lines import json +from azure.cli.core.util import sdk_no_wait -def hardwaresecuritymodules_dedicated_hsm_list(cmd, client, - resource_group_name=None, - top=None): +def hardware_security_modules_dedicated_hsm_list(client, + resource_group_name=None, + top=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name, top=top) return client.list_by_subscription(top=top) -def hardwaresecuritymodules_dedicated_hsm_show(cmd, client, - resource_group_name, - name): +def hardware_security_modules_dedicated_hsm_show(client, + resource_group_name, + name): return client.get(resource_group_name=resource_group_name, name=name) -def hardwaresecuritymodules_dedicated_hsm_create(cmd, client, - resource_group_name, - name, - location, - sku=None, - zones=None, - tags=None, - stamp_id=None, - network_profile_subnet=None, - network_profile_network_interfaces=None): - return client.begin_create_or_update(resource_group_name=resource_group_name, - name=name, - location=location, - sku=sku if not sku else {'name': sku}, - zones=zones, - tags=tags, - stamp_id=stamp_id, - subnet=network_profile_subnet, - network_interfaces=network_profile_network_interfaces) +def hardware_security_modules_dedicated_hsm_create(client, + resource_group_name, + name, + location, + zones=None, + tags=None, + stamp_id=None, + subnet=None, + network_interfaces=None, + no_wait=False): + parameters = {} + parameters['location'] = location + parameters['sku'] = json.loads("{\"name\": \"SafeNet Luna Network HSM A790\"}") + parameters['zones'] = zones + parameters['tags'] = tags + parameters['stamp_id'] = stamp_id + parameters['network_profile'] = {} + parameters['network_profile']['subnet'] = subnet + parameters['network_profile']['network_interfaces'] = network_interfaces + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + name=name, + parameters=parameters) -def hardwaresecuritymodules_dedicated_hsm_update(cmd, client, - resource_group_name, - name, - tags=None): - return client.begin_update(resource_group_name=resource_group_name, - name=name, - tags=tags) +def hardware_security_modules_dedicated_hsm_update(client, + resource_group_name, + name, + tags=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_update, + resource_group_name=resource_group_name, + name=name, + tags=tags) -def hardwaresecuritymodules_dedicated_hsm_delete(cmd, client, - resource_group_name, - name): - return client.begin_delete(resource_group_name=resource_group_name, - name=name) +def hardware_security_modules_dedicated_hsm_delete(client, + resource_group_name, + name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + name=name) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/tests/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/tests/__init__.py index df29287338d..70488e93851 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/tests/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/tests/__init__.py @@ -9,17 +9,30 @@ # regenerated. # -------------------------------------------------------------------------- import inspect +import logging import os +import sys +import traceback +import datetime as dt +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) __path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" def try_manual(func): def import_manual_function(origin_func): from importlib import import_module - decorated_path = inspect.getfile(origin_func) - module_path = __path__[0] + decorated_path = inspect.getfile(origin_func).lower() + module_path = __path__[0].lower() if not decorated_path.startswith(module_path): raise Exception("Decorator can only be used in submodules!") manual_path = os.path.join( @@ -34,16 +47,70 @@ def get_func_to_call(): func_to_call = func try: func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) except (ImportError, AttributeError): pass return func_to_call def wrapper(*args, **kwargs): func_to_call = get_func_to_call() - print("running {}()...".format(func.__name__)) - return func_to_call(*args, **kwargs) + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE") + if use_exception_cache is None or use_exception_cache.lower() != "true": + raise + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret if inspect.isclass(func): return get_func_to_call() - else: - return wrapper + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/example_steps.py b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/example_steps.py new file mode 100644 index 00000000000..9df750e9998 --- /dev/null +++ b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/example_steps.py @@ -0,0 +1,84 @@ +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + + +from .. import try_manual + + +# EXAMPLE: /DedicatedHsm/put/Create a new or update an existing dedicated HSM +@try_manual +def step_dedicated_hsm_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm create ' + '--name "hsm1" ' + '--location "westus" ' + '--network-interfaces private-ip-address="1.0.0.1" ' + '--subnet id="/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetw' + 'orks/{vn}/subnets/default" ' + '--stamp-id "{vn}" ' + '--tags Dept="hsm" Environment="dogfood" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /DedicatedHsm/get/Get a dedicated HSM +@try_manual +def step_dedicated_hsm_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm show ' + '--name "hsm1" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /DedicatedHsm/get/List dedicated HSM devices in a resource group +@try_manual +def step_dedicated_hsm_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm list ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /DedicatedHsm/get/List dedicated HSM devices in a subscription +@try_manual +def step_dedicated_hsm_list2(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm list ' + '-g ""', + checks=checks) + + +# EXAMPLE: /DedicatedHsm/patch/Update an existing dedicated HSM +@try_manual +def step_dedicated_hsm_update(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm update ' + '--name "hsm1" ' + '--tags Dept="hsm" Environment="dogfood" Slice="A" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /DedicatedHsm/delete/Delete a dedicated HSM +@try_manual +def step_dedicated_hsm_delete(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az hardware-security-modules dedicated-hsm delete -y ' + '--name "hsm1" ' + '--resource-group "{rg}"', + checks=checks) + diff --git a/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/preparers.py b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/preparers.py new file mode 100644 index 00000000000..0879e51945a --- /dev/null +++ b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/preparers.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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' +KEY_VNET_NIC = 'nic' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --subnet-name default --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + pass + + +class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.nic', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', + key=KEY_VNET_NIC): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetNicPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group[1], name, self.vnet[1])) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1])) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardware_security_modules_scenario.py b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardware_security_modules_scenario.py new file mode 100644 index 00000000000..fa7cba44f15 --- /dev/null +++ b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardware_security_modules_scenario.py @@ -0,0 +1,76 @@ +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import ScenarioTest +from azure.cli.testsdk import ResourceGroupPreparer +from .preparers import VirtualNetworkPreparer +from .example_steps import step_dedicated_hsm_create +from .example_steps import step_dedicated_hsm_show +from .example_steps import step_dedicated_hsm_list +from .example_steps import step_dedicated_hsm_list2 +from .example_steps import step_dedicated_hsm_update +from .example_steps import step_dedicated_hsm_delete +from .. import ( + try_manual, + raise_if, + calc_coverage +) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup_scenario +@try_manual +def setup_scenario(test, rg): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test, rg): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test, rg): + setup_scenario(test, rg) + step_dedicated_hsm_create(test, rg, checks=[]) + step_dedicated_hsm_show(test, rg, checks=[]) + step_dedicated_hsm_list(test, rg, checks=[]) + step_dedicated_hsm_list2(test, rg, checks=[]) + step_dedicated_hsm_update(test, rg, checks=[]) + step_dedicated_hsm_delete(test, rg, checks=[]) + cleanup_scenario(test, rg) + + +# Test class for Scenario +@try_manual +class Hardware_security_modulesScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(Hardware_security_modulesScenarioTest, self).__init__(*args, **kwargs) + self.kwargs.update({ + 'subscription_id': self.get_subscription_id() + }) + + + + @ResourceGroupPreparer(name_prefix='clitesthardware_security_modules_hsm-group'[:7], key='rg', + parameter_name='rg') + @VirtualNetworkPreparer(name_prefix='clitesthardware_security_modules_stamp01'[:7], key='vn', + resource_group_key='rg') + def test_hardware_security_modules_Scenario(self, rg): + call_scenario(self, rg) + calc_coverage(__file__) + raise_if() + diff --git a/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardwaresecuritymodules_scenario.py b/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardwaresecuritymodules_scenario.py deleted file mode 100644 index 6d2797baa72..00000000000 --- a/src/hardware-security-modules/azext_hardware_security_modules/tests/latest/test_hardwaresecuritymodules_scenario.py +++ /dev/null @@ -1,129 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import os -import unittest - -from azure_devtools.scenario_tests import AllowLargeResponse -from azure.cli.testsdk import ScenarioTest -from .. import try_manual -from azure.cli.testsdk import ResourceGroupPreparer -from azure.cli.testsdk import JMESPathCheck - - -TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) - - -@try_manual -def setup(test, rg): - test.cmd('az feature register --namespace Microsoft.HardwareSecurityModules --name AzureDedicatedHSM') - test.cmd( - 'az feature register --namespace Microsoft.Network --name AllowBaremetalServers') - test.cmd('az network vnet create --name vn -g {rg} --subnet-name default') - test.cmd( - 'az vm create -g {rg} --name vm1 --image UbuntuLTS --generate-ssh-keys') - test.cmd( - 'az network vnet subnet create --vnet-name vn -n GatewaySubnet -g {rg} --address-prefix 10.0.5.0/24') - test.cmd( - 'az network vnet subnet create --vnet-name vn -g {rg} --name hsm --address-prefixes 10.0.2.0/24 --delegations Microsoft.HardwareSecurityModules/dedicatedHSMs') - test.cmd( - 'az network public-ip create -n ERGWVIP -g {rg} --allocation-method Dynamic') - test.cmd( - 'az network vnet-gateway create -n ERGW -l japaneast --public-ip-address ERGWVIP -g {rg} --vnet vn --sku standard --gateway-type ExpressRoute') - - -# EXAMPLE: /DedicatedHsm/put/Create a new or update an existing dedicated HSM -@try_manual -def step__dedicatedhsm_put_create_a_new_or_update_an_existing_dedicated_hsm(test, rg): - test.cmd('az dedicated-hsm create ' - '--name "hsm1" ' - '--location "japaneast" ' - '--network-profile-network-interfaces private-ip-address="10.0.2.21" ' - '--subnet id="/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/vn/subnets/hsm" ' - '--stamp-id "stamp1" ' - '--sku name="SafeNet Luna Network HSM A790" ' - '--tags Dept="hsm" Environment="dogfood" ' - '--resource-group "{rg}"', - checks=[JMESPathCheck('name', 'hsm1')]) - - -# EXAMPLE: /DedicatedHsm/get/Get a dedicated HSM -@try_manual -def step__dedicatedhsm_get_get_a_dedicated_hsm(test, rg): - test.cmd('az dedicated-hsm show ' - '--name "hsm1" ' - '--resource-group "{rg}"', - checks=[JMESPathCheck('name', 'hsm1')]) - - -# EXAMPLE: /DedicatedHsm/get/List dedicated HSM devices in a resource group -@try_manual -def step__dedicatedhsm_get_list_dedicated_hsm_devices_in_a_resource_group(test, rg): - test.cmd('az dedicated-hsm list ' - '--resource-group "{rg}"', - checks=[JMESPathCheck('[0].name', 'hsm1')]) - - -# EXAMPLE: /DedicatedHsm/get/List dedicated HSM devices in a subscription -@try_manual -def step__dedicatedhsm_get_list_dedicated_hsm_devices_in_a_subscription(test, rg): - test.cmd('az dedicated-hsm list ' - '-g=', - checks=[JMESPathCheck('[0].name', 'hsm1')]) - - -# EXAMPLE: /DedicatedHsm/patch/Update an existing dedicated HSM -@try_manual -def step__dedicatedhsm_patch_update_an_existing_dedicated_hsm(test, rg): - test.cmd('az dedicated-hsm update ' - '--name "hsm1" ' - '--tags Dept="hsm" Environment="dogfood" Slice="A" ' - '--resource-group "{rg}"', - checks=[JMESPathCheck('tags.Slice', "A")]) - - -# EXAMPLE: /DedicatedHsm/delete/Delete a dedicated HSM -@try_manual -def step__dedicatedhsm_delete_delete_a_dedicated_hsm(test, rg): - test.cmd('az dedicated-hsm delete ' - '--name "hsm1" ' - '--resource-group "{rg}" ' - '-y', - checks=[]) - - -@try_manual -def call_scenario(test, rg): - try: - setup(test, rg) - step__dedicatedhsm_put_create_a_new_or_update_an_existing_dedicated_hsm( - test, rg) - step__dedicatedhsm_get_get_a_dedicated_hsm(test, rg) - step__dedicatedhsm_get_list_dedicated_hsm_devices_in_a_resource_group( - test, rg) - step__dedicatedhsm_get_list_dedicated_hsm_devices_in_a_subscription( - test, rg) - step__dedicatedhsm_patch_update_an_existing_dedicated_hsm(test, rg) - step__dedicatedhsm_delete_delete_a_dedicated_hsm(test, rg) - except: - test.cmd('az group delete -n {rg} --yes ') - - -@try_manual -class AzureDedicatedHSMResourceProviderScenarioTest(ScenarioTest): - - @ResourceGroupPreparer(name_prefix='clitesthardwaresecuritymodules_hsm-group'[:7], location='japaneast', key='rg', parameter_name='rg') - def test_hardwaresecuritymodules(self, rg): - - self.kwargs.update({ - 'subscription_id': self.get_subscription_id() - }) - - call_scenario(self, rg) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/__init__.py index da430e088ff..0385ea03c53 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/__init__.py @@ -7,13 +7,10 @@ # -------------------------------------------------------------------------- from ._azure_dedicated_hsm_resource_provider import AzureDedicatedHSMResourceProvider -from ._version import VERSION - -__version__ = VERSION __all__ = ['AzureDedicatedHSMResourceProvider'] try: - from .patch import patch_sdk + from ._patch import patch_sdk # type: ignore patch_sdk() except ImportError: pass diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_azure_dedicated_hsm_resource_provider.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_azure_dedicated_hsm_resource_provider.py index fd0731669f1..460a9a85a70 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_azure_dedicated_hsm_resource_provider.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_azure_dedicated_hsm_resource_provider.py @@ -15,7 +15,10 @@ # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional + from azure.core.credentials import TokenCredential + from ._configuration import AzureDedicatedHSMResourceProviderConfiguration +from .operations import Operations from .operations import DedicatedHsmOperations from . import models @@ -23,13 +26,16 @@ class AzureDedicatedHSMResourceProvider(object): """The Azure management API provides a RESTful set of web services that interact with Azure Dedicated HSM RP. + :ivar operations: Operations operations + :vartype operations: azure_dedicated_hsm_resource_provider.operations.Operations :ivar dedicated_hsm: DedicatedHsmOperations operations - :vartype dedicated_hsm: azure.mgmt.hardwaresecuritymodules.operations.DedicatedHsmOperations + :vartype dedicated_hsm: azure_dedicated_hsm_resource_provider.operations.DedicatedHsmOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( @@ -49,6 +55,8 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) self.dedicated_hsm = DedicatedHsmOperations( self._client, self._config, self._serialize, self._deserialize) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_configuration.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_configuration.py index ac353d6ad2e..53c46c94860 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_configuration.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/_configuration.py @@ -10,8 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies - -from ._version import VERSION +from azure.mgmt.core.policies import ARMHttpLoggingPolicy if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -19,6 +18,7 @@ from azure.core.credentials import TokenCredential +VERSION = "unknown" class AzureDedicatedHSMResourceProviderConfiguration(Configuration): """Configuration for AzureDedicatedHSMResourceProvider. @@ -48,8 +48,8 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = "2018-10-31-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - kwargs.setdefault('sdk_moniker', 'mgmt-hardwaresecuritymodules/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azurededicatedhsmresourceprovider/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -61,6 +61,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/__init__.py index 72da28df722..9bfee1d7e02 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._azure_dedicated_hsm_resource_provider_async import AzureDedicatedHSMResourceProvider +from ._azure_dedicated_hsm_resource_provider import AzureDedicatedHSMResourceProvider __all__ = ['AzureDedicatedHSMResourceProvider'] diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider_async.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider.py similarity index 73% rename from src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider_async.py rename to src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider.py index 66f3543db03..85946115e43 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider_async.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_azure_dedicated_hsm_resource_provider.py @@ -6,26 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -from ._configuration_async import AzureDedicatedHSMResourceProviderConfiguration -from .operations_async import DedicatedHsmOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import AzureDedicatedHSMResourceProviderConfiguration +from .operations import Operations +from .operations import DedicatedHsmOperations from .. import models class AzureDedicatedHSMResourceProvider(object): """The Azure management API provides a RESTful set of web services that interact with Azure Dedicated HSM RP. + :ivar operations: Operations operations + :vartype operations: azure_dedicated_hsm_resource_provider.aio.operations.Operations :ivar dedicated_hsm: DedicatedHsmOperations operations - :vartype dedicated_hsm: azure.mgmt.hardwaresecuritymodules.aio.operations_async.DedicatedHsmOperations + :vartype dedicated_hsm: azure_dedicated_hsm_resource_provider.aio.operations.DedicatedHsmOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( @@ -44,6 +52,8 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) self.dedicated_hsm = DedicatedHsmOperations( self._client, self._config, self._serialize, self._deserialize) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration_async.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration.py similarity index 86% rename from src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration_async.py rename to src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration.py index ec22f630e46..3de4ed81cd1 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration_async.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/_configuration.py @@ -10,13 +10,13 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies - -from .._version import VERSION +from azure.mgmt.core.policies import ARMHttpLoggingPolicy if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential + from azure.core.credentials_async import AsyncTokenCredential +VERSION = "unknown" class AzureDedicatedHSMResourceProviderConfiguration(Configuration): """Configuration for AzureDedicatedHSMResourceProvider. @@ -45,8 +45,8 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = "2018-10-31-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - kwargs.setdefault('sdk_moniker', 'mgmt-hardwaresecuritymodules/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azurededicatedhsmresourceprovider/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -57,6 +57,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/__init__.py similarity index 81% rename from src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/__init__.py rename to src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/__init__.py index 8322ec044b3..505a8fd156c 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/__init__.py @@ -6,8 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._dedicated_hsm_operations_async import DedicatedHsmOperations +from ._operations import Operations +from ._dedicated_hsm_operations import DedicatedHsmOperations __all__ = [ + 'Operations', 'DedicatedHsmOperations', ] diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/_dedicated_hsm_operations_async.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py similarity index 63% rename from src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/_dedicated_hsm_operations_async.py rename to src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py index 3ac7d7ff6d5..9b2edb38e65 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations_async/_dedicated_hsm_operations_async.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py @@ -5,14 +5,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -28,7 +28,7 @@ class DedicatedHsmOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hardwaresecuritymodules.models + :type models: ~azure_dedicated_hsm_resource_provider.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -47,24 +47,20 @@ async def _create_or_update_initial( self, resource_group_name: str, name: str, - location: str, - sku: Optional["models.Sku"] = None, - zones: Optional[List[str]] = None, - tags: Optional[Dict[str, str]] = None, - stamp_id: Optional[str] = None, - subnet: Optional["models.ApiEntityReference"] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, + parameters: "models.DedicatedHsm", **kwargs ) -> "models.DedicatedHsm": cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) - - _parameters = models.DedicatedHsm(location=location, sku=sku, zones=zones, tags=tags, stamp_id=stamp_id, subnet=subnet, network_interfaces=network_interfaces) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self._create_or_update_initial.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), @@ -79,14 +75,12 @@ async def _create_or_update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'DedicatedHsm') + body_content = self._serialize.body(parameters, 'DedicatedHsm') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,7 +89,6 @@ async def _create_or_update_initial( error = self._deserialize(models.DedicatedHsmError, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -103,69 +96,54 @@ async def _create_or_update_initial( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, name: str, - location: str, - sku: Optional["models.Sku"] = None, - zones: Optional[List[str]] = None, - tags: Optional[Dict[str, str]] = None, - stamp_id: Optional[str] = None, - subnet: Optional["models.ApiEntityReference"] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, + parameters: "models.DedicatedHsm", **kwargs - ) -> "models.DedicatedHsm": + ) -> AsyncLROPoller["models.DedicatedHsm"]: """Create or Update a dedicated HSM in the specified subscription. :param resource_group_name: The name of the Resource Group to which the resource belongs. :type resource_group_name: str :param name: Name of the dedicated Hsm. :type name: str - :param location: The supported Azure location where the dedicated HSM should be created. - :type location: str - :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku - :param zones: The Dedicated Hsm zones. - :type zones: list[str] - :param tags: Resource tags. - :type tags: dict[str, str] - :param stamp_id: This field will be used when RP does not support Availability zones. - :type stamp_id: str - :param subnet: Specifies the identifier of the subnet. - :type subnet: ~azure.mgmt.hardwaresecuritymodules.models.ApiEntityReference - :param network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the dedicated HSM. - :type network_interfaces: list[~azure.mgmt.hardwaresecuritymodules.models.NetworkInterface] + :param parameters: Parameters to create or update the dedicated hsm. + :type parameters: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsm :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :return: An instance of LROPoller that returns DedicatedHsm - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DedicatedHsm or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - name=name, - location=location, - sku=sku, - zones=zones, - tags=tags, - stamp_id=stamp_id, - subnet=subnet, - network_interfaces=network_interfaces, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -174,15 +152,25 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling - return await async_poller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore async def _update_initial( self, @@ -192,14 +180,18 @@ async def _update_initial( **kwargs ) -> "models.DedicatedHsm": cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) _parameters = models.DedicatedHsmPatchParameters(tags=tags) api_version = "2018-10-31-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self._update_initial.metadata['url'] + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), @@ -214,14 +206,12 @@ async def _update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_parameters, 'DedicatedHsmPatchParameters') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,18 +223,18 @@ async def _update_initial( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore - async def update( + async def begin_update( self, resource_group_name: str, name: str, tags: Optional[Dict[str, str]] = None, **kwargs - ) -> "models.DedicatedHsm": + ) -> AsyncLROPoller["models.DedicatedHsm"]: """Update a dedicated HSM in the specified subscription. :param resource_group_name: The name of the Resource Group to which the server belongs. @@ -254,23 +244,33 @@ async def update( :param tags: Resource tags. :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :return: An instance of LROPoller that returns DedicatedHsm - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DedicatedHsm or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - name=name, - tags=tags, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + name=name, + tags=tags, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -279,15 +279,25 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling - return await async_poller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore async def _delete_initial( self, @@ -296,11 +306,15 @@ async def _delete_initial( **kwargs ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" # Construct URL - url = self._delete_initial.metadata['url'] + url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str'), @@ -314,8 +328,8 @@ async def _delete_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -326,16 +340,16 @@ async def _delete_initial( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore - async def delete( + async def begin_delete( self, resource_group_name: str, name: str, **kwargs - ) -> None: + ) -> AsyncLROPoller[None]: """Deletes the specified Azure Dedicated HSM. :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. @@ -343,36 +357,56 @@ async def delete( :param name: The name of the dedicated HSM to delete. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - name=name, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + name=name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling - return await async_poller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore async def get( self, @@ -387,16 +421,20 @@ async def get( :param name: The name of the dedicated HSM. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsm or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm + :return: DedicatedHsm, or the result of cls(response) + :rtype: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsm :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str'), @@ -410,9 +448,8 @@ async def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -425,56 +462,61 @@ async def get( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def list_by_resource_group( self, resource_group_name: str, top: Optional[int] = None, **kwargs - ) -> "models.DedicatedHsmListResult": - """The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + ) -> AsyncIterable["models.DedicatedHsmListResult"]: + """The List operation gets information about the dedicated hsms associated with the subscription + and within the specified resource group. :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. :type resource_group_name: str :param top: Maximum number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsmListResult or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmListResult + :return: An iterator like instance of either DedicatedHsmListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmListResult"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -500,49 +542,53 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} # type: ignore def list_by_subscription( self, top: Optional[int] = None, **kwargs - ) -> "models.DedicatedHsmListResult": + ) -> AsyncIterable["models.DedicatedHsmListResult"]: """The List operation gets information about the dedicated HSMs associated with the subscription. :param top: Maximum number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsmListResult or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmListResult + :return: An iterator like instance of either DedicatedHsmListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmListResult"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -568,4 +614,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} # type: ignore diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_operations.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_operations.py new file mode 100644 index 00000000000..258e1acfda7 --- /dev/null +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_dedicated_hsm_resource_provider.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.DedicatedHsmOperationListResult"]: + """Get a list of Dedicated HSM operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DedicatedHsmOperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmOperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-10-31-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DedicatedHsmOperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.DedicatedHsmError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.HardwareSecurityModules/operations'} # type: ignore diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/__init__.py index f83ac526495..138456ec651 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/__init__.py @@ -11,9 +11,13 @@ from ._models_py3 import DedicatedHsm from ._models_py3 import DedicatedHsmError from ._models_py3 import DedicatedHsmListResult + from ._models_py3 import DedicatedHsmOperation + from ._models_py3 import DedicatedHsmOperationDisplay + from ._models_py3 import DedicatedHsmOperationListResult from ._models_py3 import DedicatedHsmPatchParameters from ._models_py3 import Error from ._models_py3 import NetworkInterface + from ._models_py3 import NetworkProfile from ._models_py3 import Resource from ._models_py3 import ResourceListResult from ._models_py3 import Sku @@ -22,9 +26,13 @@ from ._models import DedicatedHsm # type: ignore from ._models import DedicatedHsmError # type: ignore from ._models import DedicatedHsmListResult # type: ignore + from ._models import DedicatedHsmOperation # type: ignore + from ._models import DedicatedHsmOperationDisplay # type: ignore + from ._models import DedicatedHsmOperationListResult # type: ignore from ._models import DedicatedHsmPatchParameters # type: ignore from ._models import Error # type: ignore from ._models import NetworkInterface # type: ignore + from ._models import NetworkProfile # type: ignore from ._models import Resource # type: ignore from ._models import ResourceListResult # type: ignore from ._models import Sku # type: ignore @@ -38,9 +46,13 @@ 'DedicatedHsm', 'DedicatedHsmError', 'DedicatedHsmListResult', + 'DedicatedHsmOperation', + 'DedicatedHsmOperationDisplay', + 'DedicatedHsmOperationListResult', 'DedicatedHsmPatchParameters', 'Error', 'NetworkInterface', + 'NetworkProfile', 'Resource', 'ResourceListResult', 'Sku', diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_azure_dedicated_hsm_resource_provider_enums.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_azure_dedicated_hsm_resource_provider_enums.py index 5926034c38e..405137a2b61 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_azure_dedicated_hsm_resource_provider_enums.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_azure_dedicated_hsm_resource_provider_enums.py @@ -6,16 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass -class JsonWebKeyType(str, Enum): +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class JsonWebKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state. """ - succeeded = "Succeeded" #: The dedicated HSM has been full provisioned. - provisioning = "Provisioning" #: The dedicated HSM is currently being provisioned. - allocating = "Allocating" #: A device is currently being allocated for the dedicated HSM resource. - connecting = "Connecting" #: The dedicated HSM is being connected to the virtual network. - failed = "Failed" #: Provisioning of the dedicated HSM has failed. - checking_quota = "CheckingQuota" #: Validating the subscription has sufficient quota to allocate a dedicated HSM device. - deleting = "Deleting" #: The dedicated HSM is currently being deleted. + SUCCEEDED = "Succeeded" #: The dedicated HSM has been full provisioned. + PROVISIONING = "Provisioning" #: The dedicated HSM is currently being provisioned. + ALLOCATING = "Allocating" #: A device is currently being allocated for the dedicated HSM resource. + CONNECTING = "Connecting" #: The dedicated HSM is being connected to the virtual network. + FAILED = "Failed" #: Provisioning of the dedicated HSM has failed. + CHECKING_QUOTA = "CheckingQuota" #: Validating the subscription has sufficient quota to allocate a dedicated HSM device. + DELETING = "Deleting" #: The dedicated HSM is currently being deleted. diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models.py index 737f4e31f6e..64440d89536 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models.py @@ -47,7 +47,7 @@ class Resource(msrest.serialization.Model): created. :type location: str :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku + :type sku: ~azure_dedicated_hsm_resource_provider.models.Sku :param zones: The Dedicated Hsm zones. :type zones: list[str] :param tags: A set of tags. Resource tags. @@ -102,23 +102,21 @@ class DedicatedHsm(Resource): created. :type location: str :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku + :type sku: ~azure_dedicated_hsm_resource_provider.models.Sku :param zones: The Dedicated Hsm zones. :type zones: list[str] :param tags: A set of tags. Resource tags. :type tags: dict[str, str] + :param network_profile: Specifies the network interfaces of the dedicated hsm. + :type network_profile: ~azure_dedicated_hsm_resource_provider.models.NetworkProfile :param stamp_id: This field will be used when RP does not support Availability zones. :type stamp_id: str :ivar status_message: Resource Status Message. :vartype status_message: str :ivar provisioning_state: Provisioning state. Possible values include: "Succeeded", "Provisioning", "Allocating", "Connecting", "Failed", "CheckingQuota", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.hardwaresecuritymodules.models.JsonWebKeyType - :param subnet: Specifies the identifier of the subnet. - :type subnet: ~azure.mgmt.hardwaresecuritymodules.models.ApiEntityReference - :param network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the dedicated HSM. - :type network_interfaces: list[~azure.mgmt.hardwaresecuritymodules.models.NetworkInterface] + :vartype provisioning_state: str or + ~azure_dedicated_hsm_resource_provider.models.JsonWebKeyType """ _validation = { @@ -138,11 +136,10 @@ class DedicatedHsm(Resource): 'sku': {'key': 'sku', 'type': 'Sku'}, 'zones': {'key': 'zones', 'type': '[str]'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, 'stamp_id': {'key': 'properties.stampId', 'type': 'str'}, 'status_message': {'key': 'properties.statusMessage', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'subnet': {'key': 'properties.networkProfile.subnet', 'type': 'ApiEntityReference'}, - 'network_interfaces': {'key': 'properties.networkProfile.networkInterfaces', 'type': '[NetworkInterface]'}, } def __init__( @@ -150,11 +147,10 @@ def __init__( **kwargs ): super(DedicatedHsm, self).__init__(**kwargs) + self.network_profile = kwargs.get('network_profile', None) self.stamp_id = kwargs.get('stamp_id', None) self.status_message = None self.provisioning_state = None - self.subnet = kwargs.get('subnet', None) - self.network_interfaces = kwargs.get('network_interfaces', None) class DedicatedHsmError(msrest.serialization.Model): @@ -163,7 +159,7 @@ class DedicatedHsmError(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar error: The key vault server error. - :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.Error + :vartype error: ~azure_dedicated_hsm_resource_provider.models.Error """ _validation = { @@ -186,7 +182,7 @@ class DedicatedHsmListResult(msrest.serialization.Model): """List of dedicated HSMs. :param value: The list of dedicated HSMs. - :type value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] + :type value: list[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :param next_link: The URL to get the next set of dedicated hsms. :type next_link: str """ @@ -205,6 +201,89 @@ def __init__( self.next_link = kwargs.get('next_link', None) +class DedicatedHsmOperation(msrest.serialization.Model): + """REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: The name of the Dedicated HSM Resource Provider Operation. + :type name: str + :ivar is_data_action: Gets or sets a value indicating whether it is a data plane action. + :vartype is_data_action: str + :param display: + :type display: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperationDisplay + """ + + _validation = { + 'is_data_action': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'DedicatedHsmOperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(DedicatedHsmOperation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.is_data_action = None + self.display = kwargs.get('display', None) + + +class DedicatedHsmOperationDisplay(msrest.serialization.Model): + """DedicatedHsmOperationDisplay. + + :param provider: The Resource Provider of the operation. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param description: The object that represents the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DedicatedHsmOperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class DedicatedHsmOperationListResult(msrest.serialization.Model): + """Result of the request to list Dedicated HSM Provider operations. It contains a list of operations. + + :param value: List of Dedicated HSM Resource Provider operations. + :type value: list[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DedicatedHsmOperation]'}, + } + + def __init__( + self, + **kwargs + ): + super(DedicatedHsmOperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + class DedicatedHsmPatchParameters(msrest.serialization.Model): """Patchable properties of the dedicated HSM. @@ -234,7 +313,7 @@ class Error(msrest.serialization.Model): :ivar message: The error message. :vartype message: str :ivar inner_error: The key vault server error. - :vartype inner_error: ~azure.mgmt.hardwaresecuritymodules.models.Error + :vartype inner_error: ~azure_dedicated_hsm_resource_provider.models.Error """ _validation = { @@ -289,11 +368,35 @@ def __init__( self.private_ip_address = kwargs.get('private_ip_address', None) +class NetworkProfile(msrest.serialization.Model): + """NetworkProfile. + + :param subnet: Specifies the identifier of the subnet. + :type subnet: ~azure_dedicated_hsm_resource_provider.models.ApiEntityReference + :param network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the dedicated HSM. + :type network_interfaces: list[~azure_dedicated_hsm_resource_provider.models.NetworkInterface] + """ + + _attribute_map = { + 'subnet': {'key': 'subnet', 'type': 'ApiEntityReference'}, + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, + } + + def __init__( + self, + **kwargs + ): + super(NetworkProfile, self).__init__(**kwargs) + self.subnet = kwargs.get('subnet', None) + self.network_interfaces = kwargs.get('network_interfaces', None) + + class ResourceListResult(msrest.serialization.Model): """List of dedicated HSM resources. :param value: The list of dedicated HSM resources. - :type value: list[~azure.mgmt.hardwaresecuritymodules.models.Resource] + :type value: list[~azure_dedicated_hsm_resource_provider.models.Resource] :param next_link: The URL to get the next set of dedicated HSM resources. :type next_link: str """ diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models_py3.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models_py3.py index 1921ec0ff9e..c9a2ce29e98 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models_py3.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/models/_models_py3.py @@ -51,7 +51,7 @@ class Resource(msrest.serialization.Model): created. :type location: str :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku + :type sku: ~azure_dedicated_hsm_resource_provider.models.Sku :param zones: The Dedicated Hsm zones. :type zones: list[str] :param tags: A set of tags. Resource tags. @@ -111,23 +111,21 @@ class DedicatedHsm(Resource): created. :type location: str :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku + :type sku: ~azure_dedicated_hsm_resource_provider.models.Sku :param zones: The Dedicated Hsm zones. :type zones: list[str] :param tags: A set of tags. Resource tags. :type tags: dict[str, str] + :param network_profile: Specifies the network interfaces of the dedicated hsm. + :type network_profile: ~azure_dedicated_hsm_resource_provider.models.NetworkProfile :param stamp_id: This field will be used when RP does not support Availability zones. :type stamp_id: str :ivar status_message: Resource Status Message. :vartype status_message: str :ivar provisioning_state: Provisioning state. Possible values include: "Succeeded", "Provisioning", "Allocating", "Connecting", "Failed", "CheckingQuota", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.hardwaresecuritymodules.models.JsonWebKeyType - :param subnet: Specifies the identifier of the subnet. - :type subnet: ~azure.mgmt.hardwaresecuritymodules.models.ApiEntityReference - :param network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the dedicated HSM. - :type network_interfaces: list[~azure.mgmt.hardwaresecuritymodules.models.NetworkInterface] + :vartype provisioning_state: str or + ~azure_dedicated_hsm_resource_provider.models.JsonWebKeyType """ _validation = { @@ -147,11 +145,10 @@ class DedicatedHsm(Resource): 'sku': {'key': 'sku', 'type': 'Sku'}, 'zones': {'key': 'zones', 'type': '[str]'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, 'stamp_id': {'key': 'properties.stampId', 'type': 'str'}, 'status_message': {'key': 'properties.statusMessage', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'subnet': {'key': 'properties.networkProfile.subnet', 'type': 'ApiEntityReference'}, - 'network_interfaces': {'key': 'properties.networkProfile.networkInterfaces', 'type': '[NetworkInterface]'}, } def __init__( @@ -161,17 +158,15 @@ def __init__( sku: Optional["Sku"] = None, zones: Optional[List[str]] = None, tags: Optional[Dict[str, str]] = None, + network_profile: Optional["NetworkProfile"] = None, stamp_id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, - network_interfaces: Optional[List["NetworkInterface"]] = None, **kwargs ): super(DedicatedHsm, self).__init__(location=location, sku=sku, zones=zones, tags=tags, **kwargs) + self.network_profile = network_profile self.stamp_id = stamp_id self.status_message = None self.provisioning_state = None - self.subnet = subnet - self.network_interfaces = network_interfaces class DedicatedHsmError(msrest.serialization.Model): @@ -180,7 +175,7 @@ class DedicatedHsmError(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar error: The key vault server error. - :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.Error + :vartype error: ~azure_dedicated_hsm_resource_provider.models.Error """ _validation = { @@ -203,7 +198,7 @@ class DedicatedHsmListResult(msrest.serialization.Model): """List of dedicated HSMs. :param value: The list of dedicated HSMs. - :type value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] + :type value: list[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :param next_link: The URL to get the next set of dedicated hsms. :type next_link: str """ @@ -225,6 +220,99 @@ def __init__( self.next_link = next_link +class DedicatedHsmOperation(msrest.serialization.Model): + """REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param name: The name of the Dedicated HSM Resource Provider Operation. + :type name: str + :ivar is_data_action: Gets or sets a value indicating whether it is a data plane action. + :vartype is_data_action: str + :param display: + :type display: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperationDisplay + """ + + _validation = { + 'is_data_action': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'DedicatedHsmOperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["DedicatedHsmOperationDisplay"] = None, + **kwargs + ): + super(DedicatedHsmOperation, self).__init__(**kwargs) + self.name = name + self.is_data_action = None + self.display = display + + +class DedicatedHsmOperationDisplay(msrest.serialization.Model): + """DedicatedHsmOperationDisplay. + + :param provider: The Resource Provider of the operation. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param description: The object that represents the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(DedicatedHsmOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class DedicatedHsmOperationListResult(msrest.serialization.Model): + """Result of the request to list Dedicated HSM Provider operations. It contains a list of operations. + + :param value: List of Dedicated HSM Resource Provider operations. + :type value: list[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DedicatedHsmOperation]'}, + } + + def __init__( + self, + *, + value: Optional[List["DedicatedHsmOperation"]] = None, + **kwargs + ): + super(DedicatedHsmOperationListResult, self).__init__(**kwargs) + self.value = value + + class DedicatedHsmPatchParameters(msrest.serialization.Model): """Patchable properties of the dedicated HSM. @@ -256,7 +344,7 @@ class Error(msrest.serialization.Model): :ivar message: The error message. :vartype message: str :ivar inner_error: The key vault server error. - :vartype inner_error: ~azure.mgmt.hardwaresecuritymodules.models.Error + :vartype inner_error: ~azure_dedicated_hsm_resource_provider.models.Error """ _validation = { @@ -313,11 +401,38 @@ def __init__( self.private_ip_address = private_ip_address +class NetworkProfile(msrest.serialization.Model): + """NetworkProfile. + + :param subnet: Specifies the identifier of the subnet. + :type subnet: ~azure_dedicated_hsm_resource_provider.models.ApiEntityReference + :param network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the dedicated HSM. + :type network_interfaces: list[~azure_dedicated_hsm_resource_provider.models.NetworkInterface] + """ + + _attribute_map = { + 'subnet': {'key': 'subnet', 'type': 'ApiEntityReference'}, + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, + } + + def __init__( + self, + *, + subnet: Optional["ApiEntityReference"] = None, + network_interfaces: Optional[List["NetworkInterface"]] = None, + **kwargs + ): + super(NetworkProfile, self).__init__(**kwargs) + self.subnet = subnet + self.network_interfaces = network_interfaces + + class ResourceListResult(msrest.serialization.Model): """List of dedicated HSM resources. :param value: The list of dedicated HSM resources. - :type value: list[~azure.mgmt.hardwaresecuritymodules.models.Resource] + :type value: list[~azure_dedicated_hsm_resource_provider.models.Resource] :param next_link: The URL to get the next set of dedicated HSM resources. :type next_link: str """ diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/__init__.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/__init__.py index 1c1c2fbbddc..505a8fd156c 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/__init__.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/__init__.py @@ -6,8 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._operations import Operations from ._dedicated_hsm_operations import DedicatedHsmOperations __all__ = [ + 'Operations', 'DedicatedHsmOperations', ] diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py index 1c5a682d161..e8436edb97a 100644 --- a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse @@ -20,7 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,7 +32,7 @@ class DedicatedHsmOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hardwaresecuritymodules.models + :type models: ~azure_dedicated_hsm_resource_provider.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -51,25 +51,21 @@ def _create_or_update_initial( self, resource_group_name, # type: str name, # type: str - location, # type: str - sku=None, # type: Optional["models.Sku"] - zones=None, # type: Optional[List[str]] - tags=None, # type: Optional[Dict[str, str]] - stamp_id=None, # type: Optional[str] - subnet=None, # type: Optional["models.ApiEntityReference"] - network_interfaces=None, # type: Optional[List["NetworkInterface"]] + parameters, # type: "models.DedicatedHsm" **kwargs # type: Any ): # type: (...) -> "models.DedicatedHsm" cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) - - _parameters = models.DedicatedHsm(location=location, sku=sku, zones=zones, tags=tags, stamp_id=stamp_id, subnet=subnet, network_interfaces=network_interfaces) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self._create_or_update_initial.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), @@ -84,14 +80,12 @@ def _create_or_update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_parameters, 'DedicatedHsm') + body_content = self._serialize.body(parameters, 'DedicatedHsm') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,7 +94,6 @@ def _create_or_update_initial( error = self._deserialize(models.DedicatedHsmError, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -108,70 +101,55 @@ def _create_or_update_initial( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def begin_create_or_update( self, resource_group_name, # type: str name, # type: str - location, # type: str - sku=None, # type: Optional["models.Sku"] - zones=None, # type: Optional[List[str]] - tags=None, # type: Optional[Dict[str, str]] - stamp_id=None, # type: Optional[str] - subnet=None, # type: Optional["models.ApiEntityReference"] - network_interfaces=None, # type: Optional[List["NetworkInterface"]] + parameters, # type: "models.DedicatedHsm" **kwargs # type: Any ): - # type: (...) -> "models.DedicatedHsm" + # type: (...) -> LROPoller["models.DedicatedHsm"] """Create or Update a dedicated HSM in the specified subscription. :param resource_group_name: The name of the Resource Group to which the resource belongs. :type resource_group_name: str :param name: Name of the dedicated Hsm. :type name: str - :param location: The supported Azure location where the dedicated HSM should be created. - :type location: str - :param sku: SKU details. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku - :param zones: The Dedicated Hsm zones. - :type zones: list[str] - :param tags: Resource tags. - :type tags: dict[str, str] - :param stamp_id: This field will be used when RP does not support Availability zones. - :type stamp_id: str - :param subnet: Specifies the identifier of the subnet. - :type subnet: ~azure.mgmt.hardwaresecuritymodules.models.ApiEntityReference - :param network_interfaces: Specifies the list of resource Ids for the network interfaces - associated with the dedicated HSM. - :type network_interfaces: list[~azure.mgmt.hardwaresecuritymodules.models.NetworkInterface] + :param parameters: Parameters to create or update the dedicated hsm. + :type parameters: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsm :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.PollingMethod - :return: An instance of LROPoller that returns DedicatedHsm - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DedicatedHsm or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - name=name, - location=location, - sku=sku, - zones=zones, - tags=tags, - stamp_id=stamp_id, - subnet=subnet, - network_interfaces=network_interfaces, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + name=name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -180,15 +158,25 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def _update_initial( self, @@ -199,14 +187,18 @@ def _update_initial( ): # type: (...) -> "models.DedicatedHsm" cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) _parameters = models.DedicatedHsmPatchParameters(tags=tags) api_version = "2018-10-31-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self._update_initial.metadata['url'] + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), @@ -221,14 +213,12 @@ def _update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_parameters, 'DedicatedHsmPatchParameters') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -240,10 +230,10 @@ def _update_initial( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def begin_update( self, @@ -252,7 +242,7 @@ def begin_update( tags=None, # type: Optional[Dict[str, str]] **kwargs # type: Any ): - # type: (...) -> "models.DedicatedHsm" + # type: (...) -> LROPoller["models.DedicatedHsm"] """Update a dedicated HSM in the specified subscription. :param resource_group_name: The name of the Resource Group to which the server belongs. @@ -262,23 +252,33 @@ def begin_update( :param tags: Resource tags. :type tags: dict[str, str] :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.PollingMethod - :return: An instance of LROPoller that returns DedicatedHsm - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DedicatedHsm or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_dedicated_hsm_resource_provider.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - raw_result = self._update_initial( - resource_group_name=resource_group_name, - name=name, - tags=tags, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + name=name, + tags=tags, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DedicatedHsm', pipeline_response) @@ -287,15 +287,25 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str', pattern=r'^[a-zA-Z0-9-]{3,24}$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def _delete_initial( self, @@ -305,11 +315,15 @@ def _delete_initial( ): # type: (...) -> None cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" # Construct URL - url = self._delete_initial.metadata['url'] + url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str'), @@ -323,8 +337,8 @@ def _delete_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -335,9 +349,9 @@ def _delete_initial( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def begin_delete( self, @@ -345,7 +359,7 @@ def begin_delete( name, # type: str **kwargs # type: Any ): - # type: (...) -> None + # type: (...) -> LROPoller[None] """Deletes the specified Azure Dedicated HSM. :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. @@ -353,36 +367,56 @@ def begin_delete( :param name: The name of the dedicated HSM to delete. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.PollingMethod - :return: An instance of LROPoller that returns None + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - name=name, - cls=lambda x,y,z: x, - **kwargs + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + name=name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - lro_delay = kwargs.get( - 'polling_interval', - self._config.polling_interval - ) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def get( self, @@ -398,16 +432,20 @@ def get( :param name: The name of the dedicated HSM. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsm or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm + :return: DedicatedHsm, or the result of cls(response) + :rtype: ~azure_dedicated_hsm_resource_provider.models.DedicatedHsm :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsm"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'name': self._serialize.url("name", name, 'str'), @@ -421,9 +459,8 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -436,10 +473,10 @@ def get( deserialized = self._deserialize('DedicatedHsm', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}'} # type: ignore def list_by_resource_group( self, @@ -447,46 +484,51 @@ def list_by_resource_group( top=None, # type: Optional[int] **kwargs # type: Any ): - # type: (...) -> "models.DedicatedHsmListResult" - """The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + # type: (...) -> Iterable["models.DedicatedHsmListResult"] + """The List operation gets information about the dedicated hsms associated with the subscription + and within the specified resource group. :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. :type resource_group_name: str :param top: Maximum number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsmListResult or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmListResult + :return: An iterator like instance of either DedicatedHsmListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmListResult"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -512,50 +554,54 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} # type: ignore def list_by_subscription( self, top=None, # type: Optional[int] **kwargs # type: Any ): - # type: (...) -> "models.DedicatedHsmListResult" + # type: (...) -> Iterable["models.DedicatedHsmListResult"] """The List operation gets information about the dedicated HSMs associated with the subscription. :param top: Maximum number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedHsmListResult or the result of cls(response) - :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmListResult + :return: An iterator like instance of either DedicatedHsmListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmListResult"] - error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) api_version = "2018-10-31-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -581,4 +627,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs'} # type: ignore diff --git a/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_operations.py b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_operations.py new file mode 100644 index 00000000000..70e8ada890e --- /dev/null +++ b/src/hardware-security-modules/azext_hardware_security_modules/vendored_sdks/hardwaresecuritymodules/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_dedicated_hsm_resource_provider.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DedicatedHsmOperationListResult"] + """Get a list of Dedicated HSM operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DedicatedHsmOperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dedicated_hsm_resource_provider.models.DedicatedHsmOperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DedicatedHsmOperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-10-31-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DedicatedHsmOperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.DedicatedHsmError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.HardwareSecurityModules/operations'} # type: ignore diff --git a/src/hardware-security-modules/report.md b/src/hardware-security-modules/report.md index aae7def24e8..6bd269efaf7 100644 --- a/src/hardware-security-modules/report.md +++ b/src/hardware-security-modules/report.md @@ -1,50 +1,107 @@ # Azure CLI Module Creation Report -### hardwaresecuritymodules dedicated-hsm create - -create a hardwaresecuritymodules dedicated-hsm. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--resource-group-name**|string|The name of the Resource Group to which the resource belongs.|resource_group_name| -|**--name**|string|Name of the dedicated Hsm|name| -|**--location**|string|The supported Azure location where the dedicated HSM should be created.|location| -|**--sku**|object|SKU details|sku| -|**--zones**|array|The Dedicated Hsm zones.|zones| -|**--tags**|dictionary|Resource tags|tags| -|**--stamp-id**|string|This field will be used when RP does not support Availability zones.|stamp_id| -|**--network-profile-subnet**|object|Specifies the identifier of the subnet.|subnet| -|**--network-profile-network-interfaces**|array|Specifies the list of resource Ids for the network interfaces associated with the dedicated HSM.|network_interfaces| -### hardwaresecuritymodules dedicated-hsm delete - -delete a hardwaresecuritymodules dedicated-hsm. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--resource-group-name**|string|The name of the Resource Group to which the dedicated HSM belongs.|resource_group_name| -|**--name**|string|The name of the dedicated HSM to delete|name| -### hardwaresecuritymodules dedicated-hsm list - -list a hardwaresecuritymodules dedicated-hsm. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--resource-group-name**|string|The name of the Resource Group to which the dedicated HSM belongs.|resource_group_name| -|**--top**|integer|Maximum number of results to return.|top| -### hardwaresecuritymodules dedicated-hsm show - -show a hardwaresecuritymodules dedicated-hsm. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--resource-group-name**|string|The name of the Resource Group to which the dedicated hsm belongs.|resource_group_name| -|**--name**|string|The name of the dedicated HSM.|name| -### hardwaresecuritymodules dedicated-hsm update - -update a hardwaresecuritymodules dedicated-hsm. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--resource-group-name**|string|The name of the Resource Group to which the server belongs.|resource_group_name| -|**--name**|string|Name of the dedicated HSM|name| -|**--tags**|dictionary|Resource tags|tags| \ No newline at end of file +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az hardware-security-modules|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az hardware-security-modules` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az hardware-security-modules dedicated-hsm|DedicatedHsm|[commands](#CommandsInDedicatedHsm)| + +## COMMANDS +### Commands in `az hardware-security-modules dedicated-hsm` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az hardware-security-modules dedicated-hsm list](#DedicatedHsmListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersDedicatedHsmListByResourceGroup)|[Example](#ExamplesDedicatedHsmListByResourceGroup)| +|[az hardware-security-modules dedicated-hsm list](#DedicatedHsmListBySubscription)|ListBySubscription|[Parameters](#ParametersDedicatedHsmListBySubscription)|[Example](#ExamplesDedicatedHsmListBySubscription)| +|[az hardware-security-modules dedicated-hsm show](#DedicatedHsmGet)|Get|[Parameters](#ParametersDedicatedHsmGet)|[Example](#ExamplesDedicatedHsmGet)| +|[az hardware-security-modules dedicated-hsm create](#DedicatedHsmCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersDedicatedHsmCreateOrUpdate#Create)|[Example](#ExamplesDedicatedHsmCreateOrUpdate#Create)| +|[az hardware-security-modules dedicated-hsm update](#DedicatedHsmUpdate)|Update|[Parameters](#ParametersDedicatedHsmUpdate)|[Example](#ExamplesDedicatedHsmUpdate)| +|[az hardware-security-modules dedicated-hsm delete](#DedicatedHsmDelete)|Delete|[Parameters](#ParametersDedicatedHsmDelete)|[Example](#ExamplesDedicatedHsmDelete)| + + +## COMMAND DETAILS + +### group `az hardware-security-modules dedicated-hsm` +#### Command `az hardware-security-modules dedicated-hsm list` + +##### Example +``` +az hardware-security-modules dedicated-hsm list --resource-group "hsm-group" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the Resource Group to which the dedicated HSM belongs.|resource_group_name|resourceGroupName| +|**--top**|integer|Maximum number of results to return.|top|$top| + +#### Command `az hardware-security-modules dedicated-hsm list` + +##### Example +``` +az hardware-security-modules dedicated-hsm list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az hardware-security-modules dedicated-hsm show` + +##### Example +``` +az hardware-security-modules dedicated-hsm show --name "hsm1" --resource-group "hsm-group" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the Resource Group to which the dedicated hsm belongs.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the dedicated HSM.|name|name| + +#### Command `az hardware-security-modules dedicated-hsm create` + +##### Example +``` +az hardware-security-modules dedicated-hsm create --name "hsm1" --location "westus" --network-interfaces \ +private-ip-address="1.0.0.1" --subnet id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/\ +providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" --stamp-id "stamp01" --tags Dept="hsm" \ +Environment="dogfood" --resource-group "hsm-group" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the Resource Group to which the resource belongs.|resource_group_name|resourceGroupName| +|**--name**|string|Name of the dedicated Hsm|name|name| +|**--location**|string|The supported Azure location where the dedicated HSM should be created.|location|location| +|**--zones**|array|The Dedicated Hsm zones.|zones|zones| +|**--tags**|dictionary|Resource tags|tags|tags| +|**--stamp-id**|string|This field will be used when RP does not support Availability zones.|stamp_id|stampId| +|**--subnet**|object|Specifies the identifier of the subnet.|subnet|subnet| +|**--network-interfaces**|array|Specifies the list of resource Ids for the network interfaces associated with the dedicated HSM.|network_interfaces|networkInterfaces| + +#### Command `az hardware-security-modules dedicated-hsm update` + +##### Example +``` +az hardware-security-modules dedicated-hsm update --name "hsm1" --tags Dept="hsm" Environment="dogfood" Slice="A" \ +--resource-group "hsm-group" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the Resource Group to which the server belongs.|resource_group_name|resourceGroupName| +|**--name**|string|Name of the dedicated HSM|name|name| +|**--tags**|dictionary|Resource tags|tags|tags| + +#### Command `az hardware-security-modules dedicated-hsm delete` + +##### Example +``` +az hardware-security-modules dedicated-hsm delete --name "hsm1" --resource-group "hsm-group" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the Resource Group to which the dedicated HSM belongs.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the dedicated HSM to delete|name|name| diff --git a/src/hardware-security-modules/setup.cfg b/src/hardware-security-modules/setup.cfg index e69de29bb2d..2fdd96e5d39 100644 --- a/src/hardware-security-modules/setup.cfg +++ b/src/hardware-security-modules/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/hardware-security-modules/setup.py b/src/hardware-security-modules/setup.py index 9dc91de47ee..ccb4309a9c6 100644 --- a/src/hardware-security-modules/setup.py +++ b/src/hardware-security-modules/setup.py @@ -9,9 +9,12 @@ from codecs import open from setuptools import setup, find_packages -# TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. VERSION = '0.1.0' +try: + from azext_hardware_security_modules.manual.version import VERSION +except ImportError: + pass # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -27,23 +30,25 @@ 'License :: OSI Approved :: MIT License', ] -# TODO: Add any additional SDK dependencies here DEPENDENCIES = [] +try: + from azext_hardware_security_modules.manual.dependency import DEPENDENCIES +except ImportError: + pass + 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='hardware-security-modules', + name='hardware_security_modules', version=VERSION, description='Microsoft Azure Command-Line Tools AzureDedicatedHSMResourceProvider Extension', - # TODO: Update author and email, if applicable author='Microsoft Corporation', author_email='azpycli@microsoft.com', - # TODO: consider pointing directly to your source code instead of the generic repo - url='https://github.com/Azure/azure-cli-extensions', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/hardware-security-modules', long_description=README + '\n\n' + HISTORY, license='MIT', classifiers=CLASSIFIERS,