From f23378a51e3413101930d60b777e69d136fe8148 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 21 Jun 2021 15:05:29 +0000 Subject: [PATCH] CodeGen from PR 14908 in Azure/azure-rest-api-specs Merge 2f8a27c7263bdfa50b39cc00dbc07312e8f4e2d9 into c7616be749e60dc269e2bb50800f06dbca065098 --- src/account/HISTORY.rst | 11 - src/account/README.md | 59 +++++ src/account/README.rst | 5 - src/account/azext_account/.flake8 | 3 - src/account/azext_account/__init__.py | 23 +- src/account/azext_account/action.py | 16 +- src/account/azext_account/azext_metadata.json | 2 +- src/account/azext_account/custom.py | 16 +- .../azext_account/generated/__init__.py | 14 +- .../generated/_client_factory.py | 32 ++- src/account/azext_account/generated/_help.py | 115 +++++---- .../azext_account/generated/_params.py | 66 ++--- .../azext_account/generated/_validators.py | 23 +- src/account/azext_account/generated/action.py | 47 ++++ .../azext_account/generated/commands.py | 44 ++-- src/account/azext_account/generated/custom.py | 66 +++-- .../version.py => manual/__init__.py} | 3 +- src/account/azext_account/tests/__init__.py | 116 +++++++++ .../azext_account/tests/latest/__init__.py | 12 + .../tests/latest/example_steps.py | 114 +++++++++ .../tests/latest/test_account_scenario.py | 163 ++++++------ .../vendored_sdks/subscription/__init__.py | 3 + .../subscription/_configuration.py | 8 +- .../subscription/_subscription_client.py | 27 +- .../vendored_sdks/subscription/_version.py | 9 + .../subscription/aio/__init__.py | 2 +- ...nfiguration_async.py => _configuration.py} | 8 +- ...lient_async.py => _subscription_client.py} | 33 ++- .../__init__.py | 14 +- .../_alias_operations.py} | 58 +++-- .../_operations.py} | 17 +- .../operations/_subscription_operations.py | 211 +++++++++++++++ .../_subscriptions_operations.py} | 205 ++------------- .../_tenants_operations.py} | 17 +- .../subscription/models/_models.py | 39 ++- .../subscription/models/_models_py3.py | 39 ++- .../subscription/operations/__init__.py | 10 +- .../operations/_alias_operations.py | 58 +++-- .../operations/_operation_operations.py | 90 ------- .../subscription/operations/_operations.py | 96 +++---- .../_subscription_operation_operations.py | 104 -------- .../operations/_subscription_operations.py | 226 ++-------------- .../operations/_subscriptions_operations.py | 236 +++++++++++++++++ ...t_operations.py => _tenants_operations.py} | 17 +- .../vendored_sdks/subscription/setup.py | 37 +++ src/account/report.md | 241 ++++++++++++------ src/account/setup.cfg | 1 + src/account/setup.py | 21 +- 48 files changed, 1625 insertions(+), 1152 deletions(-) create mode 100644 src/account/README.md delete mode 100644 src/account/README.rst delete mode 100644 src/account/azext_account/.flake8 create mode 100644 src/account/azext_account/generated/action.py rename src/account/azext_account/{vendored_sdks/subscription/version.py => manual/__init__.py} (88%) create mode 100644 src/account/azext_account/tests/__init__.py create mode 100644 src/account/azext_account/tests/latest/__init__.py create mode 100644 src/account/azext_account/tests/latest/example_steps.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/_version.py rename src/account/azext_account/vendored_sdks/subscription/aio/{_configuration_async.py => _configuration.py} (91%) rename src/account/azext_account/vendored_sdks/subscription/aio/{_subscription_client_async.py => _subscription_client.py} (71%) rename src/account/azext_account/vendored_sdks/subscription/aio/{operations_async => operations}/__init__.py (61%) rename src/account/azext_account/vendored_sdks/subscription/aio/{operations_async/_alias_operations_async.py => operations/_alias_operations.py} (86%) rename src/account/azext_account/vendored_sdks/subscription/aio/{operations_async/_operation_operations_async.py => operations/_operations.py} (85%) create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscription_operations.py rename src/account/azext_account/vendored_sdks/subscription/aio/{operations_async/_subscription_operations_async.py => operations/_subscriptions_operations.py} (50%) rename src/account/azext_account/vendored_sdks/subscription/aio/{operations_async/_tenant_operations_async.py => operations/_tenants_operations.py} (86%) delete mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py delete mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_subscriptions_operations.py rename src/account/azext_account/vendored_sdks/subscription/operations/{_tenant_operations.py => _tenants_operations.py} (87%) create mode 100644 src/account/azext_account/vendored_sdks/subscription/setup.py diff --git a/src/account/HISTORY.rst b/src/account/HISTORY.rst index ff58ed4c0b9..1c139576ba0 100644 --- a/src/account/HISTORY.rst +++ b/src/account/HISTORY.rst @@ -3,17 +3,6 @@ Release History =============== -0.2.1 -+++++ -* az account alias create: add --reseller-id - -0.2.0 -+++++ -* Breaking Change: remove `az account subscription create`. -* Add az account alias commands. -* Add az account tenant commands. -* Support sovereign clouds. - 0.1.0 ++++++ * Initial release. diff --git a/src/account/README.md b/src/account/README.md new file mode 100644 index 00000000000..6ef47b47010 --- /dev/null +++ b/src/account/README.md @@ -0,0 +1,59 @@ +# Azure CLI account Extension # +This is the extension for account + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name account +``` + +### Included Features ### +#### account subscription #### +##### List ##### +``` +az account subscription list +``` +##### Show ##### +``` +az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### List-location ##### +``` +az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +#### account tenant #### +##### List ##### +``` +az account tenant list +``` +#### account subscription #### +##### Cancel ##### +``` +az account subscription cancel --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### Enable ##### +``` +az account subscription enable --subscription-id "7948bcee-488c-47ce-941c-38e20ede803d" +``` +##### Rename ##### +``` +az account subscription rename --name "Test Sub" --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +#### account alias #### +##### Create ##### +``` +az account alias create --name "aliasForNewSub" \ + --properties billing-scope="/providers/Microsoft.Billing/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload="Production" +``` +##### Show ##### +``` +az account alias show --name "aliasForNewSub" +``` +##### List ##### +``` +az account alias list +``` +##### Delete ##### +``` +az account alias delete --name "aliasForNewSub" +``` \ No newline at end of file diff --git a/src/account/README.rst b/src/account/README.rst deleted file mode 100644 index f97748cd85d..00000000000 --- a/src/account/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -Microsoft Azure CLI 'account' Extension -========================================== - -This package is for the 'account' extension. -i.e. 'az account' diff --git a/src/account/azext_account/.flake8 b/src/account/azext_account/.flake8 deleted file mode 100644 index 2e3d72769f9..00000000000 --- a/src/account/azext_account/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -exclude = - vendored_sdks diff --git a/src/account/azext_account/__init__.py b/src/account/azext_account/__init__.py index 6d41a06806a..4b3db57b8e3 100644 --- a/src/account/azext_account/__init__.py +++ b/src/account/azext_account/__init__.py @@ -1,22 +1,31 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. +# -------------------------------------------------------------------------- from azure.cli.core import AzCommandsLoader from azext_account.generated._help import helps # pylint: disable=unused-import +try: + from azext_account.manual._help import helps # pylint: disable=reimported +except ImportError: + pass class SubscriptionClientCommandsLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType - from azext_account.generated._client_factory import cf_account + from azext_account.generated._client_factory import cf_account_cl account_custom = CliCommandType( operations_tmpl='azext_account.custom#{}', - client_factory=cf_account) - super(SubscriptionClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=account_custom) + client_factory=cf_account_cl) + parent = super(SubscriptionClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=account_custom) def load_command_table(self, args): from azext_account.generated.commands import load_command_table diff --git a/src/account/azext_account/action.py b/src/account/azext_account/action.py index b6a13c7554b..d95d53bf711 100644 --- a/src/account/azext_account/action.py +++ b/src/account/azext_account/action.py @@ -1,13 +1,17 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. +# -------------------------------------------------------------------------- # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import -# from azext_account.generated.action import * # noqa: F403 +from .generated.action import * # noqa: F403 try: - from azext_account.manual.action import * # noqa: F403 + from .manual.action import * # noqa: F403 except ImportError: pass diff --git a/src/account/azext_account/azext_metadata.json b/src/account/azext_account/azext_metadata.json index 13025150393..cfc30c747c7 100644 --- a/src/account/azext_account/azext_metadata.json +++ b/src/account/azext_account/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/account/azext_account/custom.py b/src/account/azext_account/custom.py index 928085d9009..dbe9d5f9742 100644 --- a/src/account/azext_account/custom.py +++ b/src/account/azext_account/custom.py @@ -1,13 +1,17 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. +# -------------------------------------------------------------------------- # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import -from azext_account.generated.custom import * # noqa: F403 +from .generated.custom import * # noqa: F403 try: - from azext_account.manual.custom import * # noqa: F403 + from .manual.custom import * # noqa: F403 except ImportError: pass diff --git a/src/account/azext_account/generated/__init__.py b/src/account/azext_account/generated/__init__.py index 34913fb394d..c9cfdc73e77 100644 --- a/src/account/azext_account/generated/__init__.py +++ b/src/account/azext_account/generated/__init__.py @@ -1,4 +1,12 @@ -# -------------------------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index 3ded7eafb49..d437cf67469 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -1,24 +1,32 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. +# -------------------------------------------------------------------------- -def cf_account(cli_ctx, *_): - from azure.cli.core.commands.client_factory import _get_mgmt_service_client - from ..vendored_sdks.subscription import SubscriptionClient - return _get_mgmt_service_client(cli_ctx, SubscriptionClient, - subscription_bound=False, - base_url_bound=True)[0] +def cf_account_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azext_account.vendored_sdks.subscription import SubscriptionClient + return get_mgmt_service_client(cli_ctx, + SubscriptionClient) def cf_subscription(cli_ctx, *_): - return cf_account(cli_ctx).subscription + return cf_account_cl(cli_ctx).subscriptions def cf_tenant(cli_ctx, *_): - return cf_account(cli_ctx).tenant + return cf_account_cl(cli_ctx).tenants + + +def cf_subscription(cli_ctx, *_): + return cf_account_cl(cli_ctx).subscription def cf_alias(cli_ctx, *_): - return cf_account(cli_ctx).alias + return cf_account_cl(cli_ctx).alias diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 59e2266ad36..2e054ef8f63 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -1,8 +1,12 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long +# 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. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines from knack.help_files import helps @@ -10,95 +14,101 @@ helps['account subscription'] = """ type: group - short-summary: Manage subscriptions + short-summary: Manage subscription with account """ -helps['account subscription rename'] = """ +helps['account subscription list'] = """ type: command - short-summary: Rename subscription + short-summary: "Gets all subscriptions for a tenant." examples: - - name: Rename subscription + - name: listSubscriptions text: |- - az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription list """ -helps['account subscription cancel'] = """ +helps['account subscription show'] = """ type: command - short-summary: Cancel subscription + short-summary: "Gets details about a specified subscription." examples: - - name: Cancel subscription + - name: getSubscription text: |- - az account subscription cancel --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" """ -helps['account subscription enable'] = """ +helps['account subscription list-location'] = """ type: command - short-summary: Enable subscription + short-summary: "This operation provides all the locations that are available for resource providers; however, each \ +resource provider may support a subset of this list." examples: - - name: Enable subscription + - name: listLocations text: |- - az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" """ -helps['account subscription list'] = """ +helps['account tenant'] = """ + type: group + short-summary: Manage tenant with account +""" + +helps['account tenant list'] = """ type: command - short-summary: Get all subscriptions for a tenant. + short-summary: "Gets the tenants for your account." examples: - - name: listSubscriptions + - name: listTenants text: |- - az account subscription list + az account tenant list """ -helps['account subscription show'] = """ +helps['account subscription'] = """ + type: group + short-summary: Manage subscription with account +""" + +helps['account subscription cancel'] = """ type: command - short-summary: Get details about a specified subscription. + short-summary: "The operation to cancel a subscription." examples: - - name: getSubscription + - name: cancelSubscription text: |- - az account subscription show --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription cancel --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" """ -helps['account subscription list-location'] = """ +helps['account subscription enable'] = """ type: command - short-summary: This operation provides all the locations that are available for resource providers; however, each r\ -esource provider may support a subset of this list. + short-summary: "The operation to enable a subscription." examples: - - name: listLocations + - name: enableSubscription text: |- - az account subscription list-location --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription enable --subscription-id "7948bcee-488c-47ce-941c-38e20ede803d" """ -helps['account tenant'] = """ - type: group - short-summary: Manage tenant -""" - -helps['account tenant list'] = """ +helps['account subscription rename'] = """ type: command - short-summary: Get the tenants for your account. + short-summary: "The operation to rename a subscription." examples: - - name: listTenants + - name: renameSubscription text: |- - az account tenant list + az account subscription rename --name "Test Sub" --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad\ +" """ helps['account alias'] = """ type: group - short-summary: Manage subscription alias + short-summary: Manage alias with account """ helps['account alias list'] = """ type: command - short-summary: List Alias Subscriptions. + short-summary: "Get Alias Subscription." examples: - - name: List Alias Subscriptions + - name: GetAlias text: |- az account alias list """ helps['account alias show'] = """ type: command - short-summary: Get Alias Subscription. + short-summary: "Get Alias Subscription." examples: - name: GetAlias text: |- @@ -108,17 +118,28 @@ helps['account alias create'] = """ type: command short-summary: "Create Alias Subscription." + parameters: + - name: --properties + short-summary: "Put alias request properties." + long-summary: | + Usage: --properties display-name=XX workload=XX billing-scope=XX subscription-id=XX reseller-id=XX + + display-name: The friendly name of the subscription. + workload: The workload type of the subscription. It can be either Production or DevTest. + billing-scope: Determines whether subscription is fieldLed, partnerLed or LegacyEA + subscription-id: This parameter can be used to create alias for existing subscription Id + reseller-id: Reseller ID, basically MPN Id examples: - name: CreateAlias text: |- - az account alias create --name "aliasForNewSub" --billing-scope "/providers/Microsoft.Billing/billingAcc\ -ounts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG\ -7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" --display-name "Contoso MCA subscription" --workload "Production" + az account alias create --name "aliasForNewSub" --properties billing-scope="/providers/Microsoft.Billing\ +/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/P\ +E2Q-NOIT-BG7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload="Production" """ helps['account alias delete'] = """ type: command - short-summary: Delete Alias. + short-summary: "Delete Alias." examples: - name: DeleteAlias text: |- diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index f04b068caa2..cf156923dca 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -1,58 +1,46 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long +# 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. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from azure.cli.core.commands.parameters import get_enum_type -from ._validators import alias_validator +from azext_account.action import AddProperties def load_arguments(self, _): - with self.argument_context('account subscription rename') as c: - c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='Subscription Id.') - c.argument('subscription_name', options_list=['--name', '-n', '--subscription-name'], help='New subscription name') - - with self.argument_context('account subscription cancel') as c: - c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='Subscription Id.') - - with self.argument_context('account subscription enable') as c: - c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='Subscription Id.') - - with self.argument_context('account subscription list') as c: - pass - with self.argument_context('account subscription show') as c: - c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.', id_part='subscription') + c.argument('subscription_id', type=str, help='The ID of the target subscription.', id_part='subscription') with self.argument_context('account subscription list-location') as c: - c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.') + c.argument('subscription_id', type=str, help='The ID of the target subscription.') + + with self.argument_context('account subscription cancel') as c: + c.argument('subscription_id', type=str, help='Subscription Id.', id_part='subscription') - with self.argument_context('account tenant list') as c: - pass + with self.argument_context('account subscription enable') as c: + c.argument('subscription_id', type=str, help='Subscription Id.', id_part='subscription') - with self.argument_context('account alias list') as c: - pass + with self.argument_context('account subscription rename') as c: + c.argument('subscription_id', type=str, help='Subscription Id.', id_part='subscription') + c.argument('subscription_name', options_list=['--name', '-n', '--subscription-name'], type=str, help='New ' + 'subscription name') with self.argument_context('account alias show') as c: - c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') - - with self.argument_context('account alias create', validator=alias_validator) as c: - c.argument('alias_name', options_list=['--name', '-n'], type=str, help='Alias Name') - c.argument('display_name', type=str, help='The friendly name of the subscription.') - c.argument('workload', arg_type=get_enum_type(['Production', 'DevTest']), help='The workload type of the ' - 'subscription. It can be either Production or DevTest.') - c.argument('billing_scope', type=str, help='Billing scope. It determines whether the subscription is Field-Led, Partner-Led or ' - 'LegacyEA') - c.argument('subscription_id', type=str, help='This parameter can be used to create alias for existing ' - 'subscription ID') - c.argument('reseller_id', type=str, help='Reseller ID, basically MPN Id') + c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], type=str, help='Alias Name') + + with self.argument_context('account alias create') as c: + c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], type=str, help='Alias Name') + c.argument('properties', action=AddProperties, nargs='+', help='Put alias request properties.') with self.argument_context('account alias delete') as c: - c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') + c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], type=str, help='Alias Name') with self.argument_context('account alias wait') as c: - c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') + c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], type=str, help='Alias Name') diff --git a/src/account/azext_account/generated/_validators.py b/src/account/azext_account/generated/_validators.py index 798183f12a4..b33a44c1ebf 100644 --- a/src/account/azext_account/generated/_validators.py +++ b/src/account/azext_account/generated/_validators.py @@ -1,16 +1,9 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from knack.util import CLIError - - -def alias_validator(namespace): - if namespace.subscription_id: - if namespace.billing_scope or namespace.display_name: - raise CLIError('--billing-scope or --display-name is not allowed when --subscription-id is provided.') - else: - if not namespace.billing_scope or not namespace.display_name or not namespace.workload: - raise CLIError('--billing-scope, --display-name and --workload are required when creating ' - 'an alias with a new susbcription.') +# 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. +# -------------------------------------------------------------------------- diff --git a/src/account/azext_account/generated/action.py b/src/account/azext_account/generated/action.py new file mode 100644 index 00000000000..cf3a7584f51 --- /dev/null +++ b/src/account/azext_account/generated/action.py @@ -0,0 +1,47 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from collections import defaultdict +from knack.util import CLIError + + +class AddProperties(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.properties = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'display-name': + d['display_name'] = v[0] + elif kl == 'workload': + d['workload'] = v[0] + elif kl == 'billing-scope': + d['billing_scope'] = v[0] + elif kl == 'subscription-id': + d['subscription_id'] = v[0] + elif kl == 'reseller-id': + d['reseller_id'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter properties. All possible keys are: ' + 'display-name, workload, billing-scope, subscription-id, reseller-id'.format(k)) + return d diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index 24fcc3ed2e4..dbd88ff9c86 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -1,12 +1,15 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=line-too-long -# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- # pylint: disable=too-many-statements # pylint: disable=too-many-locals + from azure.cli.core.commands import CliCommandType @@ -14,30 +17,41 @@ def load_command_table(self, _): from azext_account.generated._client_factory import cf_subscription account_subscription = CliCommandType( - operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}', + operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscriptions_operations#SubscriptionsOpe' + 'rations.{}', client_factory=cf_subscription) - with self.command_group('account subscription', account_subscription, client_factory=cf_subscription, is_experimental=True) as g: - g.custom_command('rename', 'account_subscription_rename') - g.custom_command('cancel', 'account_subscription_cancel', confirmation=True) - g.custom_command('enable', 'account_subscription_enable') + with self.command_group('account subscription', account_subscription, client_factory=cf_subscription) as g: g.custom_command('list', 'account_subscription_list') g.custom_show_command('show', 'account_subscription_show') g.custom_command('list-location', 'account_subscription_list_location') from azext_account.generated._client_factory import cf_tenant account_tenant = CliCommandType( - operations_tmpl='azext_account.vendored_sdks.subscription.operations._tenant_operations#TenantOperations.{}', + operations_tmpl='azext_account.vendored_sdks.subscription.operations._tenants_operations#TenantsOperations.{}', client_factory=cf_tenant) - with self.command_group('account tenant', account_tenant, client_factory=cf_tenant, is_experimental=True) as g: + with self.command_group('account tenant', account_tenant, client_factory=cf_tenant) as g: g.custom_command('list', 'account_tenant_list') + from azext_account.generated._client_factory import cf_subscription + account_subscription = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOpera' + 'tions.{}', + client_factory=cf_subscription) + with self.command_group('account subscription', account_subscription, client_factory=cf_subscription) as g: + g.custom_command('cancel', 'account_subscription_cancel') + g.custom_command('enable', 'account_subscription_enable') + g.custom_command('rename', 'account_subscription_rename') + from azext_account.generated._client_factory import cf_alias account_alias = CliCommandType( operations_tmpl='azext_account.vendored_sdks.subscription.operations._alias_operations#AliasOperations.{}', client_factory=cf_alias) - with self.command_group('account alias', account_alias, client_factory=cf_alias, is_experimental=True) as g: + with self.command_group('account alias', account_alias, client_factory=cf_alias) as g: g.custom_command('list', 'account_alias_list') g.custom_show_command('show', 'account_alias_show') g.custom_command('create', 'account_alias_create', supports_no_wait=True) - g.custom_command('delete', 'account_alias_delete') + g.custom_command('delete', 'account_alias_delete', confirmation=True) g.custom_wait_command('wait', 'account_alias_show') + + with self.command_group('account', is_experimental=True): + pass diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 824ac5ff9de..16b79ee3eba 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -1,29 +1,17 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long -# pylint: disable=too-many-statements +# 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. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines -# pylint: disable=too-many-locals -# pylint: disable=unused-argument from azure.cli.core.util import sdk_no_wait -def account_subscription_rename(cmd, client, subscription_id, - subscription_name=None): - return client.rename(subscription_id=subscription_id, subscription_name=subscription_name) - - -def account_subscription_cancel(cmd, client, subscription_id): - return client.cancel(subscription_id=subscription_id) - - -def account_subscription_enable(cmd, client, subscription_id): - return client.enable(subscription_id=subscription_id) - - def account_subscription_list(client): return client.list() @@ -35,13 +23,32 @@ def account_subscription_show(client, def account_subscription_list_location(client, subscription_id): - return client.list_location(subscription_id=subscription_id) + return client.list_locations(subscription_id=subscription_id) def account_tenant_list(client): return client.list() +def account_subscription_cancel(client, + subscription_id): + return client.cancel(subscription_id=subscription_id) + + +def account_subscription_enable(client, + subscription_id): + return client.enable(subscription_id=subscription_id) + + +def account_subscription_rename(client, + subscription_id, + subscription_name=None): + body = {} + body['subscription_name'] = subscription_name + return client.rename(subscription_id=subscription_id, + body=body) + + def account_alias_list(client): return client.list() @@ -53,23 +60,14 @@ def account_alias_show(client, def account_alias_create(client, alias_name, - workload=None, - billing_scope=None, - display_name=None, - subscription_id=None, - reseller_id=None, + properties, no_wait=False): - properties = { - 'display_name': display_name, - 'workload': workload, - 'billing_scope': billing_scope, - 'subscription_id': subscription_id, - 'reseller_id': reseller_id - } + body = {} + body['properties'] = properties return sdk_no_wait(no_wait, client.begin_create, alias_name=alias_name, - properties=properties) + body=body) def account_alias_delete(client, diff --git a/src/account/azext_account/vendored_sdks/subscription/version.py b/src/account/azext_account/manual/__init__.py similarity index 88% rename from src/account/azext_account/vendored_sdks/subscription/version.py rename to src/account/azext_account/manual/__init__.py index 266f5a486d7..c9cfdc73e77 100644 --- a/src/account/azext_account/vendored_sdks/subscription/version.py +++ b/src/account/azext_account/manual/__init__.py @@ -9,5 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.5.0" - +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/tests/__init__.py b/src/account/azext_account/tests/__init__.py new file mode 100644 index 00000000000..70488e93851 --- /dev/null +++ b/src/account/azext_account/tests/__init__.py @@ -0,0 +1,116 @@ +# 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. +# -------------------------------------------------------------------------- +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).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( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + 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() + 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() + 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/account/azext_account/tests/latest/__init__.py b/src/account/azext_account/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/account/azext_account/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/tests/latest/example_steps.py b/src/account/azext_account/tests/latest/example_steps.py new file mode 100644 index 00000000000..7b045f04847 --- /dev/null +++ b/src/account/azext_account/tests/latest/example_steps.py @@ -0,0 +1,114 @@ +# -------------------------------------------------------------------------- +# 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: /Alias/put/CreateAlias +@try_manual +def step_alias_create(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account alias create ' + '--name "{myAlias}" ' + '--properties billing-scope="/providers/Microsoft.Billing/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc986' + '8693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG7-TGB/invoiceSections/MT' + 'T4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload="Production"', + checks=checks) + + +# EXAMPLE: /Alias/get/GetAlias +@try_manual +def step_alias_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account alias list', + checks=checks) + + +# EXAMPLE: /Alias/delete/DeleteAlias +@try_manual +def step_alias_delete(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account alias delete -y ' + '--name "{myAlias}"', + checks=checks) + + +# EXAMPLE: /Subscriptions/get/getSubscription +@try_manual +def step_subscription_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription show ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=checks) + + +# EXAMPLE: /Subscriptions/get/listLocations +@try_manual +def step_subscription_list_location(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription list-location ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=checks) + + +# EXAMPLE: /Subscriptions/get/listSubscriptions +@try_manual +def step_subscription_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription list', + checks=checks) + + +# EXAMPLE: /Subscription/post/cancelSubscription +@try_manual +def step_subscription_cancel(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription cancel ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=checks) + + +# EXAMPLE: /Subscription/post/enableSubscription +@try_manual +def step_subscription_enable(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription enable ' + '--subscription-id "7948bcee-488c-47ce-941c-38e20ede803d"', + checks=checks) + + +# EXAMPLE: /Subscription/post/renameSubscription +@try_manual +def step_subscription_rename(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account subscription rename ' + '--name "{mySubscription}" ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=checks) + + +# EXAMPLE: /Tenants/get/listTenants +@try_manual +def step_tenant_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az account tenant list', + checks=checks) + diff --git a/src/account/azext_account/tests/latest/test_account_scenario.py b/src/account/azext_account/tests/latest/test_account_scenario.py index 78782e18d1c..e434ddd0ee7 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -1,104 +1,85 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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. +# -------------------------------------------------------------------------- import os -import unittest -import time - -from azure_devtools.scenario_tests import AllowLargeResponse -from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) +from azure.cli.testsdk import ScenarioTest +from .example_steps import step_alias_create +from .example_steps import step_alias_list +from .example_steps import step_alias_delete +from .example_steps import step_subscription_show +from .example_steps import step_subscription_list_location +from .example_steps import step_subscription_list +from .example_steps import step_subscription_cancel +from .example_steps import step_subscription_enable +from .example_steps import step_subscription_rename +from .example_steps import step_tenant_list +from .. import ( + try_manual, + raise_if, + calc_coverage +) TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) -class SubscriptionClientScenarioTest(ScenarioTest): - - # @ResourceGroupPreparer(name_prefix='cli_test_account') - def test_account(self): +# Env setup_scenario +@try_manual +def setup_scenario(test): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test): + setup_scenario(test) + step_alias_create(test, checks=[ + test.check("name", "{myAlias}", case_sensitive=False), + ]) + step_alias_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_alias_list(test, checks=[ + test.check('length(@)', 1), + ]) + step_alias_delete(test, checks=[]) + step_subscription_show(test, checks=[]) + step_subscription_list_location(test, checks=[]) + step_subscription_list(test, checks=[]) + step_subscription_cancel(test, checks=[]) + step_subscription_enable(test, checks=[]) + step_subscription_rename(test, checks=[]) + step_tenant_list(test, checks=[]) + cleanup_scenario(test) + + +# Test class for Scenario +@try_manual +class AccountScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(AccountScenarioTest, self).__init__(*args, **kwargs) self.kwargs.update({ - 'alias_name': self.create_random_name(prefix='cli_alias', length=24), - 'new_alias_name': self.create_random_name(prefix='cli_alias_new', length=24), - 'display_name': "My Subscription", - 'new_display_name': "My Big Subscription", - 'billing_scope': "/providers/Microsoft.Billing/billingAccounts/9147924/enrollmentAccounts/253727", - 'reseller_id': "5139005" + 'mySubscription': 'Test Sub', + 'myAlias': 'aliasForNewSub', }) - self.cmd('az account alias create --name {alias_name} --billing-scope "{billing_scope}" --display-name "{display_name}" --workload "Production" --reseller-id {reseller_id}', - checks=[self.check('name', '{alias_name}'), - self.check('properties.provisioningState', 'Succeeded')]) - - alias_sub = self.cmd('az account alias show -n {alias_name}', - checks=[self.check('name', '{alias_name}'), - self.check('properties.provisioningState', 'Succeeded')]).get_output_in_json() - sub_id = alias_sub['properties']['subscriptionId'] - self.kwargs.update({'subscription_id': sub_id}) - - self.cmd('az account alias list', - checks=[self.exists('value')]) - - self.cmd('az account subscription list', - checks=[self.greater_than('length(@)', 0)]) - - self.cmd('az account subscription show --subscription-id {subscription_id}', - checks=[self.check('displayName', '{display_name}'), - self.check('state', 'Enabled'), - self.check('subscriptionId', sub_id)]) - - self.cmd('az account subscription list-location --subscription-id {subscription_id}', - checks=[self.greater_than('length(@)', 0)]) - - self.cmd('az account subscription cancel --subscription-id {subscription_id} --yes', - checks=[self.check('subscriptionId', '{subscription_id}')]) - time.sleep(300) - for i in range(5): - sub = self.cmd('az account subscription show --subscription-id {subscription_id}', - checks=[self.check('displayName', '{display_name}'), - self.check('subscriptionId', sub_id)]).get_output_in_json() - if sub['state'] != 'Warned': - time.sleep(180) - self.assertEquals(sub['state'], 'Warned') - - self.cmd('az account subscription enable --subscription-id {subscription_id}', - checks=[self.check('subscriptionId', '{subscription_id}')]) - time.sleep(300) - for i in range(10): - sub = self.cmd('az account subscription show --subscription-id {subscription_id}', - checks=[self.check('displayName', '{display_name}'), - self.check('subscriptionId', sub_id)]).get_output_in_json() - if sub['state'] != 'Enabled': - time.sleep(180) - self.assertEquals(sub['state'], 'Enabled') - - self.cmd('az account subscription rename --subscription-id {subscription_id} --name "{new_display_name}"', - checks=[self.check('subscriptionId', '{subscription_id}')]) - # uncomment when request body match is supported in playback tests - # time.sleep(600) - # self.cmd('az account subscription show --subscription-id {subscription_id}', - # checks=[ - # self.check('displayName', '{new_display_name}'), - # self.check('state', 'Enabled'), - # self.check('subscriptionId', sub_id)]) - - self.cmd('az account tenant list', - checks=[self.exists('[0].tenantId')]) - - self.cmd('az account alias delete -n {alias_name}', - checks=[]) - self.cmd('az account alias create --name {new_alias_name} --workload "Production" --subscription-id {subscription_id}', - checks=[self.check('name', '{new_alias_name}'), - self.check('properties.provisioningState', 'Succeeded')]) + def test_account_Scenario(self): + call_scenario(self) + calc_coverage(__file__) + raise_if() - time.sleep(600) - for i in range(10): - try: - self.cmd('az account alias delete -n {new_alias_name}', checks=[]) - break - except Exception as ex: - if i == 9: - raise ex - time.sleep(180) diff --git a/src/account/azext_account/vendored_sdks/subscription/__init__.py b/src/account/azext_account/vendored_sdks/subscription/__init__.py index a1d3eed7425..6d8f45c77a6 100644 --- a/src/account/azext_account/vendored_sdks/subscription/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/__init__.py @@ -7,6 +7,9 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient +from ._version import VERSION + +__version__ = VERSION __all__ = ['SubscriptionClient'] try: diff --git a/src/account/azext_account/vendored_sdks/subscription/_configuration.py b/src/account/azext_account/vendored_sdks/subscription/_configuration.py index b7302055ff8..5915e6fc841 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_configuration.py +++ b/src/account/azext_account/vendored_sdks/subscription/_configuration.py @@ -12,13 +12,14 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from ._version import VERSION + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential -VERSION = "unknown" class SubscriptionClientConfiguration(Configuration): """Configuration for SubscriptionClient. @@ -41,9 +42,8 @@ def __init__( super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) - kwargs.setdefault('sdk_moniker', 'subscriptionclient/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py b/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py index d06f83460ca..462b26f0342 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py +++ b/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py @@ -18,9 +18,10 @@ from azure.core.credentials import TokenCredential from ._configuration import SubscriptionClientConfiguration +from .operations import SubscriptionsOperations +from .operations import TenantsOperations from .operations import SubscriptionOperations -from .operations import TenantOperations -from .operations import OperationOperations +from .operations import Operations from .operations import AliasOperations from . import models @@ -28,14 +29,16 @@ class SubscriptionClient(object): """The subscription client. + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.subscription.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.subscription.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: subscription_client.operations.SubscriptionOperations - :ivar tenant: TenantOperations operations - :vartype tenant: subscription_client.operations.TenantOperations - :ivar operation: OperationOperations operations - :vartype operation: subscription_client.operations.OperationOperations + :vartype subscription: azure.mgmt.subscription.operations.SubscriptionOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.subscription.operations.Operations :ivar alias: AliasOperations operations - :vartype alias: subscription_client.operations.AliasOperations + :vartype alias: azure.mgmt.subscription.operations.AliasOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param str base_url: Service URL @@ -58,11 +61,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.subscription = SubscriptionOperations( + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( self._client, self._config, self._serialize, self._deserialize) - self.tenant = TenantOperations( + self.subscription = SubscriptionOperations( self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations( + self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( self._client, self._config, self._serialize, self._deserialize) diff --git a/src/account/azext_account/vendored_sdks/subscription/_version.py b/src/account/azext_account/vendored_sdks/subscription/_version.py new file mode 100644 index 00000000000..e5754a47ce6 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/_version.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py b/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py index 345034cd293..25a76f1a699 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._subscription_client_async import SubscriptionClient +from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration.py similarity index 91% rename from src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/_configuration.py index 799e460b7d1..7d6a38539dd 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration.py @@ -12,11 +12,12 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from .._version import VERSION + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" class SubscriptionClientConfiguration(Configuration): """Configuration for SubscriptionClient. @@ -38,9 +39,8 @@ def __init__( super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) - kwargs.setdefault('sdk_moniker', 'subscriptionclient/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client.py similarity index 71% rename from src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client.py index 92ce5f10d73..1f648309fc6 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client.py @@ -15,25 +15,28 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration_async import SubscriptionClientConfiguration -from .operations_async import SubscriptionOperations -from .operations_async import TenantOperations -from .operations_async import OperationOperations -from .operations_async import AliasOperations +from ._configuration import SubscriptionClientConfiguration +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionOperations +from .operations import Operations +from .operations import AliasOperations from .. import models class SubscriptionClient(object): """The subscription client. + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.subscription.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.subscription.aio.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations - :ivar tenant: TenantOperations operations - :vartype tenant: subscription_client.aio.operations_async.TenantOperations - :ivar operation: OperationOperations operations - :vartype operation: subscription_client.aio.operations_async.OperationOperations + :vartype subscription: azure.mgmt.subscription.aio.operations.SubscriptionOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.subscription.aio.operations.Operations :ivar alias: AliasOperations operations - :vartype alias: subscription_client.aio.operations_async.AliasOperations + :vartype alias: azure.mgmt.subscription.aio.operations.AliasOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param str base_url: Service URL @@ -55,11 +58,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.subscription = SubscriptionOperations( + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( self._client, self._config, self._serialize, self._deserialize) - self.tenant = TenantOperations( + self.subscription = SubscriptionOperations( self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations( + self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( self._client, self._config, self._serialize, self._deserialize) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/__init__.py similarity index 61% rename from src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py rename to src/account/azext_account/vendored_sdks/subscription/aio/operations/__init__.py index 7aac3e6b7f8..4831f8016e9 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/__init__.py @@ -6,14 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._subscription_operations_async import SubscriptionOperations -from ._tenant_operations_async import TenantOperations -from ._operation_operations_async import OperationOperations -from ._alias_operations_async import AliasOperations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_operations import SubscriptionOperations +from ._operations import Operations +from ._alias_operations import AliasOperations __all__ = [ + 'SubscriptionsOperations', + 'TenantsOperations', 'SubscriptionOperations', - 'TenantOperations', - 'OperationOperations', + 'Operations', 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_alias_operations.py similarity index 86% rename from src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/operations/_alias_operations.py index 5b6584fd311..5db6ce2a1ca 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_alias_operations.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union 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.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -27,7 +27,7 @@ class AliasOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,16 +45,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def _create_initial( self, alias_name: str, - properties: "models.PutAliasRequestProperties", + body: "models.PutAliasRequest", **kwargs ) -> "models.PutAliasResponse": cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - - _body = models.PutAliasRequest(properties=properties) api_version = "2020-09-01" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self._create_initial.metadata['url'] # type: ignore @@ -70,13 +71,12 @@ async def _create_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') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content = self._serialize.body(body, 'PutAliasRequest') 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 @@ -100,15 +100,15 @@ async def _create_initial( async def begin_create( self, alias_name: str, - properties: "models.PutAliasRequestProperties", + body: "models.PutAliasRequest", **kwargs ) -> AsyncLROPoller["models.PutAliasResponse"]: """Create Alias Subscription. :param alias_name: Alias Name. :type alias_name: str - :param properties: Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :param body: + :type body: ~azure.mgmt.subscription.models.PutAliasRequest :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 @@ -116,7 +116,7 @@ async def begin_create( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :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 PutAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~subscription_client.models.PutAliasResponse] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.subscription.models.PutAliasResponse] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] @@ -129,7 +129,7 @@ async def begin_create( if cont_token is None: raw_result = await self._create_initial( alias_name=alias_name, - properties=properties, + body=body, cls=lambda x,y,z: x, **kwargs ) @@ -144,7 +144,11 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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 if cont_token: @@ -169,13 +173,16 @@ async def get( :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PutAliasResponse, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasResponse + :rtype: ~azure.mgmt.subscription.models.PutAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -190,7 +197,7 @@ 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') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -224,9 +231,12 @@ async def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -241,6 +251,7 @@ async def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -264,13 +275,16 @@ async def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: PutAliasListResult, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasListResult + :rtype: ~azure.mgmt.subscription.models.PutAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.list.metadata['url'] # type: ignore @@ -281,7 +295,7 @@ async def list( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_operations.py similarity index 85% rename from src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/operations/_operations.py index 25c797735e9..66b4a226a8a 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_operations.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Generic, Optional, TypeVar 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.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat @@ -18,14 +18,14 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationOperations: - """OperationOperations async operations. +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: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -48,13 +48,16 @@ async def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult, or the result of cls(response) - :rtype: ~subscription_client.models.OperationListResult + :rtype: ~azure.mgmt.subscription.models.OperationListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.list.metadata['url'] # type: ignore @@ -65,7 +68,7 @@ async def list( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscription_operations.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscription_operations.py new file mode 100644 index 00000000000..60055fc50e5 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscription_operations.py @@ -0,0 +1,211 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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 SubscriptionOperations: + """SubscriptionOperations 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.mgmt.subscription.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 + + async def cancel( + self, + subscription_id: str, + **kwargs + ) -> "models.CanceledSubscriptionId": + """The operation to cancel a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CanceledSubscriptionId, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + accept = "application/json" + + # Construct URL + url = self.cancel.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + + async def rename( + self, + subscription_id: str, + body: "models.SubscriptionName", + **kwargs + ) -> "models.RenamedSubscriptionId": + """The operation to rename a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param body: Subscription Name. + :type body: ~azure.mgmt.subscription.models.SubscriptionName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RenamedSubscriptionId, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.rename.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'SubscriptionName') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + + async def enable( + self, + subscription_id: str, + **kwargs + ) -> "models.EnabledSubscriptionId": + """The operation to enable a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnabledSubscriptionId, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + accept = "application/json" + + # Construct URL + url = self.enable.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscriptions_operations.py similarity index 50% rename from src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscriptions_operations.py index 287209147a0..77c06aebe22 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_subscriptions_operations.py @@ -9,7 +9,7 @@ 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.mgmt.core.exceptions import ARMErrorFormat @@ -19,14 +19,14 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SubscriptionOperations: - """SubscriptionOperations async operations. +class SubscriptionsOperations: + """SubscriptionsOperations 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: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,7 +41,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list_location( + def list_locations( self, subscription_id: str, **kwargs @@ -55,22 +55,25 @@ def list_location( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.LocationListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2016-06-01" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL - url = self.list_location.metadata['url'] # type: ignore + url = self.list_locations.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } @@ -108,7 +111,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_location.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore async def get( self, @@ -121,13 +124,16 @@ async def get( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Subscription, or the result of cls(response) - :rtype: ~subscription_client.models.Subscription + :rtype: ~azure.mgmt.subscription.models.Subscription :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2016-06-01" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -142,7 +148,7 @@ 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') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -168,18 +174,21 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.SubscriptionListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2016-06-01" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -218,167 +227,3 @@ async def get_next(next_link=None): get_next, extract_data ) list.metadata = {'url': '/subscriptions'} # type: ignore - - async def cancel( - self, - subscription_id: str, - **kwargs - ) -> "models.CanceledSubscriptionId": - """The operation to cancel a subscription. - - :param subscription_id: Subscription Id. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CanceledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.CanceledSubscriptionId - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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' - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore - - async def rename( - self, - subscription_id: str, - subscription_name: Optional[str] = None, - **kwargs - ) -> "models.RenamedSubscriptionId": - """The operation to rename a subscription. - - :param subscription_id: Subscription Id. - :type subscription_id: str - :param subscription_name: New subscription name. - :type subscription_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RenamedSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.RenamedSubscriptionId - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - - _body = models.SubscriptionName(subscription_name=subscription_name) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.rename.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # 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' - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'SubscriptionName') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore - - async def enable( - self, - subscription_id: str, - **kwargs - ) -> "models.EnabledSubscriptionId": - """The operation to enable a subscription. - - :param subscription_id: Subscription Id. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnabledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.EnabledSubscriptionId - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - - # Construct URL - url = self.enable.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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' - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_tenants_operations.py similarity index 86% rename from src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py rename to src/account/azext_account/vendored_sdks/subscription/aio/operations/_tenants_operations.py index 06120525696..056588537a9 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations/_tenants_operations.py @@ -9,7 +9,7 @@ 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.mgmt.core.exceptions import ARMErrorFormat @@ -19,14 +19,14 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantOperations: - """TenantOperations async operations. +class TenantsOperations: + """TenantsOperations 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: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -49,18 +49,21 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.TenantListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2016-06-01" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_models.py b/src/account/azext_account/vendored_sdks/subscription/models/_models.py index 9c37458d737..63e811b0224 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -87,7 +87,7 @@ class ErrorResponseBody(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. :param error: The details of the error. - :type error: ~subscription_client.models.ErrorResponse + :type error: ~azure.mgmt.subscription.models.ErrorResponse """ _attribute_map = { @@ -157,7 +157,7 @@ class LocationListResult(msrest.serialization.Model): """Location list operation response. :param value: An array of locations. - :type value: list[~subscription_client.models.Location] + :type value: list[~azure.mgmt.subscription.models.Location] """ _attribute_map = { @@ -178,7 +178,7 @@ class Operation(msrest.serialization.Model): :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that represents the operation. - :type display: ~subscription_client.models.OperationDisplay + :type display: ~azure.mgmt.subscription.models.OperationDisplay """ _attribute_map = { @@ -226,7 +226,7 @@ class OperationListResult(msrest.serialization.Model): """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~subscription_client.models.Operation] + :type value: list[~azure.mgmt.subscription.models.Operation] :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -251,7 +251,7 @@ class PutAliasListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of alias. - :vartype value: list[~subscription_client.models.PutAliasResponse] + :vartype value: list[~azure.mgmt.subscription.models.PutAliasResponse] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ @@ -281,7 +281,7 @@ class PutAliasRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param properties: Required. Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ _validation = { @@ -303,15 +303,12 @@ def __init__( class PutAliasRequestProperties(msrest.serialization.Model): """Put subscription properties. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. The friendly name of the subscription. + :param display_name: The friendly name of the subscription. :type display_name: str - :param workload: Required. The workload type of the subscription. It can be either Production - or DevTest. Possible values include: "Production", "DevTest". - :type workload: str or ~subscription_client.models.Workload - :param billing_scope: Required. Determines whether subscription is fieldLed, partnerLed or - LegacyEA. + :param workload: The workload type of the subscription. It can be either Production or DevTest. + Possible values include: "Production", "DevTest". + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param billing_scope: Determines whether subscription is fieldLed, partnerLed or LegacyEA. :type billing_scope: str :param subscription_id: This parameter can be used to create alias for existing subscription Id. @@ -352,7 +349,7 @@ class PutAliasResponse(msrest.serialization.Model): :ivar type: Resource type, Microsoft.Subscription/aliases. :vartype type: str :param properties: Put Alias response properties. - :type properties: ~subscription_client.models.PutAliasResponseProperties + :type properties: ~azure.mgmt.subscription.models.PutAliasResponseProperties """ _validation = { @@ -388,7 +385,7 @@ class PutAliasResponseProperties(msrest.serialization.Model): :vartype subscription_id: str :param provisioning_state: The provisioning state of the resource. Possible values include: "Accepted", "Succeeded", "Failed". - :type provisioning_state: str or ~subscription_client.models.ProvisioningState + :type provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState """ _validation = { @@ -448,9 +445,9 @@ class Subscription(msrest.serialization.Model): :vartype display_name: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". - :vartype state: str or ~subscription_client.models.SubscriptionState + :vartype state: str or ~azure.mgmt.subscription.models.SubscriptionState :param subscription_policies: The subscription policies. - :type subscription_policies: ~subscription_client.models.SubscriptionPolicies + :type subscription_policies: ~azure.mgmt.subscription.models.SubscriptionPolicies :param authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. @@ -492,7 +489,7 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: An array of subscriptions. - :type value: list[~subscription_client.models.Subscription] + :type value: list[~azure.mgmt.subscription.models.Subscription] :param next_link: Required. The URL to get the next set of results. :type next_link: str """ @@ -547,7 +544,7 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype quota_id: str :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", "CurrentPeriodOff". - :vartype spending_limit: str or ~subscription_client.models.SpendingLimit + :vartype spending_limit: str or ~azure.mgmt.subscription.models.SpendingLimit """ _validation = { @@ -609,7 +606,7 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: An array of tenants. - :type value: list[~subscription_client.models.TenantIdDescription] + :type value: list[~azure.mgmt.subscription.models.TenantIdDescription] :param next_link: Required. The URL to use for getting the next set of results. :type next_link: str """ diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py b/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py index 7453e60d805..806a5ed75c5 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py @@ -94,7 +94,7 @@ class ErrorResponseBody(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. :param error: The details of the error. - :type error: ~subscription_client.models.ErrorResponse + :type error: ~azure.mgmt.subscription.models.ErrorResponse """ _attribute_map = { @@ -166,7 +166,7 @@ class LocationListResult(msrest.serialization.Model): """Location list operation response. :param value: An array of locations. - :type value: list[~subscription_client.models.Location] + :type value: list[~azure.mgmt.subscription.models.Location] """ _attribute_map = { @@ -189,7 +189,7 @@ class Operation(msrest.serialization.Model): :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that represents the operation. - :type display: ~subscription_client.models.OperationDisplay + :type display: ~azure.mgmt.subscription.models.OperationDisplay """ _attribute_map = { @@ -244,7 +244,7 @@ class OperationListResult(msrest.serialization.Model): """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~subscription_client.models.Operation] + :type value: list[~azure.mgmt.subscription.models.Operation] :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -272,7 +272,7 @@ class PutAliasListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of alias. - :vartype value: list[~subscription_client.models.PutAliasResponse] + :vartype value: list[~azure.mgmt.subscription.models.PutAliasResponse] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ @@ -302,7 +302,7 @@ class PutAliasRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param properties: Required. Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ _validation = { @@ -326,15 +326,12 @@ def __init__( class PutAliasRequestProperties(msrest.serialization.Model): """Put subscription properties. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. The friendly name of the subscription. + :param display_name: The friendly name of the subscription. :type display_name: str - :param workload: Required. The workload type of the subscription. It can be either Production - or DevTest. Possible values include: "Production", "DevTest". - :type workload: str or ~subscription_client.models.Workload - :param billing_scope: Required. Determines whether subscription is fieldLed, partnerLed or - LegacyEA. + :param workload: The workload type of the subscription. It can be either Production or DevTest. + Possible values include: "Production", "DevTest". + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param billing_scope: Determines whether subscription is fieldLed, partnerLed or LegacyEA. :type billing_scope: str :param subscription_id: This parameter can be used to create alias for existing subscription Id. @@ -381,7 +378,7 @@ class PutAliasResponse(msrest.serialization.Model): :ivar type: Resource type, Microsoft.Subscription/aliases. :vartype type: str :param properties: Put Alias response properties. - :type properties: ~subscription_client.models.PutAliasResponseProperties + :type properties: ~azure.mgmt.subscription.models.PutAliasResponseProperties """ _validation = { @@ -419,7 +416,7 @@ class PutAliasResponseProperties(msrest.serialization.Model): :vartype subscription_id: str :param provisioning_state: The provisioning state of the resource. Possible values include: "Accepted", "Succeeded", "Failed". - :type provisioning_state: str or ~subscription_client.models.ProvisioningState + :type provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState """ _validation = { @@ -481,9 +478,9 @@ class Subscription(msrest.serialization.Model): :vartype display_name: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". - :vartype state: str or ~subscription_client.models.SubscriptionState + :vartype state: str or ~azure.mgmt.subscription.models.SubscriptionState :param subscription_policies: The subscription policies. - :type subscription_policies: ~subscription_client.models.SubscriptionPolicies + :type subscription_policies: ~azure.mgmt.subscription.models.SubscriptionPolicies :param authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. @@ -528,7 +525,7 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: An array of subscriptions. - :type value: list[~subscription_client.models.Subscription] + :type value: list[~azure.mgmt.subscription.models.Subscription] :param next_link: Required. The URL to get the next set of results. :type next_link: str """ @@ -588,7 +585,7 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype quota_id: str :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", "CurrentPeriodOff". - :vartype spending_limit: str or ~subscription_client.models.SpendingLimit + :vartype spending_limit: str or ~azure.mgmt.subscription.models.SpendingLimit """ _validation = { @@ -650,7 +647,7 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: An array of tenants. - :type value: list[~subscription_client.models.TenantIdDescription] + :type value: list[~azure.mgmt.subscription.models.TenantIdDescription] :param next_link: Required. The URL to use for getting the next set of results. :type next_link: str """ diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py b/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py index 7b42bb434c7..4831f8016e9 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py @@ -6,14 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations -from ._tenant_operations import TenantOperations -from ._operation_operations import OperationOperations +from ._operations import Operations from ._alias_operations import AliasOperations __all__ = [ + 'SubscriptionsOperations', + 'TenantsOperations', 'SubscriptionOperations', - 'TenantOperations', - 'OperationOperations', + 'Operations', 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py index 6fcfec9abc2..cebd7d922ef 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod @@ -31,7 +31,7 @@ class AliasOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -49,17 +49,18 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, alias_name, # type: str - properties, # type: "models.PutAliasRequestProperties" + body, # type: "models.PutAliasRequest" **kwargs # type: Any ): # type: (...) -> "models.PutAliasResponse" cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - - _body = models.PutAliasRequest(properties=properties) api_version = "2020-09-01" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self._create_initial.metadata['url'] # type: ignore @@ -75,13 +76,12 @@ def _create_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') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content = self._serialize.body(body, 'PutAliasRequest') 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 @@ -105,7 +105,7 @@ def _create_initial( def begin_create( self, alias_name, # type: str - properties, # type: "models.PutAliasRequestProperties" + body, # type: "models.PutAliasRequest" **kwargs # type: Any ): # type: (...) -> LROPoller["models.PutAliasResponse"] @@ -113,8 +113,8 @@ def begin_create( :param alias_name: Alias Name. :type alias_name: str - :param properties: Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :param body: + :type body: ~azure.mgmt.subscription.models.PutAliasRequest :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 @@ -122,7 +122,7 @@ def begin_create( :paramtype polling: bool or ~azure.core.polling.PollingMethod :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 PutAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.PutAliasResponse] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.subscription.models.PutAliasResponse] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] @@ -135,7 +135,7 @@ def begin_create( if cont_token is None: raw_result = self._create_initial( alias_name=alias_name, - properties=properties, + body=body, cls=lambda x,y,z: x, **kwargs ) @@ -150,7 +150,11 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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 if cont_token: @@ -176,13 +180,16 @@ def get( :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PutAliasResponse, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasResponse + :rtype: ~azure.mgmt.subscription.models.PutAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -197,7 +204,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -232,9 +239,12 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -249,6 +259,7 @@ def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -273,13 +284,16 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: PutAliasListResult, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasListResult + :rtype: ~azure.mgmt.subscription.models.PutAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.list.metadata['url'] # type: ignore @@ -290,7 +304,7 @@ def list( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py deleted file mode 100644 index ad81bbff54c..00000000000 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py +++ /dev/null @@ -1,90 +0,0 @@ -# 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -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, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class OperationOperations(object): - """OperationOperations 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: ~subscription_client.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: (...) -> "models.OperationListResult" - """Lists all of the available Microsoft.Subscription API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) - :rtype: ~subscription_client.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - - # 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py index 664844824d5..b0c8d0c517c 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py @@ -1,89 +1,93 @@ # 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. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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, 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 directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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.mgmt.subscription.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. - :ivar api_version: Version of the API to be used with the client request. Current version is 2019-10-01-preview. Constant value: "2019-10-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01-preview" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> "models.OperationListResult" """Lists all of the available Microsoft.Subscription API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OperationListResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.OperationListResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + accept = "application/json" + # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationListResult', response) + deserialized = self._deserialize('OperationListResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} + list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py deleted file mode 100644 index ff4eaf571ec..00000000000 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class SubscriptionOperationOperations(object): - """SubscriptionOperationOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Current version is 2019-10-01-preview. Constant value: "2019-10-01-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-10-01-preview" - - self.config = config - - def get( - self, operation_id, custom_headers=None, raw=False, **operation_config): - """Get the status of the pending Microsoft.Subscription API operations. - - :param operation_id: The operation ID, which can be found from the - Location field in the generate recommendation response header. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SubscriptionCreationResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.SubscriptionCreationResult or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'operationId': self._serialize.url("operation_id", operation_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - return deserialized - get.metadata = {'url': '/providers/Microsoft.Subscription/subscriptionOperations/{operationId}'} diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py index 9e068481e4c..40170450be9 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py @@ -8,8 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.mgmt.core.exceptions import ARMErrorFormat @@ -18,7 +17,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -30,7 +29,7 @@ class SubscriptionOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,187 +44,6 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list_location( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.LocationListResult"] - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - if not next_link: - # Construct URL - url = self.list_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # 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('LocationListResult', 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_location.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - def get( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Subscription" - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~subscription_client.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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' - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.SubscriptionListResult"] - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - 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('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore - def cancel( self, subscription_id, # type: str @@ -238,13 +56,16 @@ def cancel( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CanceledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.CanceledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.cancel.metadata['url'] # type: ignore @@ -259,7 +80,7 @@ def cancel( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -281,7 +102,7 @@ def cancel( def rename( self, subscription_id, # type: str - subscription_name=None, # type: Optional[str] + body, # type: "models.SubscriptionName" **kwargs # type: Any ): # type: (...) -> "models.RenamedSubscriptionId" @@ -289,20 +110,21 @@ def rename( :param subscription_id: Subscription Id. :type subscription_id: str - :param subscription_name: New subscription name. - :type subscription_name: str + :param body: Subscription Name. + :type body: ~azure.mgmt.subscription.models.SubscriptionName :keyword callable cls: A custom type or function that will be passed the direct response :return: RenamedSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.RenamedSubscriptionId + :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - - _body = models.SubscriptionName(subscription_name=subscription_name) api_version = "2020-09-01" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self.rename.metadata['url'] # type: ignore @@ -318,13 +140,12 @@ def rename( # 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') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'SubscriptionName') + body_content = self._serialize.body(body, 'SubscriptionName') body_content_kwargs['content'] = body_content request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -353,13 +174,16 @@ def enable( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EnabledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.EnabledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-09-01" + accept = "application/json" # Construct URL url = self.enable.metadata['url'] # type: ignore @@ -374,7 +198,7 @@ def enable( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscriptions_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..6d00bd144a0 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_subscriptions_operations.py @@ -0,0 +1,236 @@ +# 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 SubscriptionsOperations(object): + """SubscriptionsOperations 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.mgmt.subscription.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_locations( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + 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_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # 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('LocationListResult', 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + 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('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_tenants_operations.py similarity index 87% rename from src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py rename to src/account/azext_account/vendored_sdks/subscription/operations/_tenants_operations.py index 57584209e20..3df0f51ccd1 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_tenants_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 @@ -23,14 +23,14 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class TenantOperations(object): - """TenantOperations operations. +class TenantsOperations(object): + """TenantsOperations 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: ~subscription_client.models + :type models: ~azure.mgmt.subscription.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -54,18 +54,21 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.TenantListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2016-06-01" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL diff --git a/src/account/azext_account/vendored_sdks/subscription/setup.py b/src/account/azext_account/vendored_sdks/subscription/setup.py new file mode 100644 index 00000000000..2094f7e05de --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/setup.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "azure-mgmt-subscription" +VERSION = "1.0.0b1" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="azure-mgmt-subscription", + author_email="", + url="", + keywords=["Swagger", "SubscriptionClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + The subscription client. + """ +) diff --git a/src/account/report.md b/src/account/report.md index dbffaf42067..5ee4d73ebec 100644 --- a/src/account/report.md +++ b/src/account/report.md @@ -1,75 +1,170 @@ # Azure CLI Module Creation Report -### account operation list - -list a account operation. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription cancel - -cancel a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription create-csp-subscription - -create-csp-subscription a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|**--display-name**|string|The friendly name of the subscription.|/something/my_option|/something/myOption| -|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|/something/my_option|/something/myOption| -|--reseller-id**|string|Reseller ID, basically MPN Id.|/something/my_option|/something/myOption| -### account subscription create-subscription - -create-subscription a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|**--display-name**|string|The friendly name of the subscription.|/something/my_option|/something/myOption| -|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|/something/my_option|/something/myOption| -|--cost-center**|string|If set, the cost center will show up on the Azure usage and charges file.|/something/my_option|/something/myOption| -|--owner**|object|Active Directory Principal who’ll get owner access on the new subscription.|/something/my_option|/something/myOption| -|--management-group-id**|string|The identifier of the management group to which this subscription will be associated.|/something/my_option|/something/myOption| -### account subscription create-subscription-in-enrollment-account - -create-subscription-in-enrollment-account a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|--display-name**|string|The display name of the subscription.|/something/my_option|/something/myOption| -|--management-group-id**|string|The Management Group Id.|/something/my_option|/something/myOption| -|--owners**|array|The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.|/something/my_option|/something/myOption| -|--offer-type**|choice|The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope.|/something/my_option|/something/myOption| -### account subscription enable - -enable a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription rename - -rename a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|Subscription Name|/something/my_option|/something/myOption| -|--subscription-name**|string|New subscription name|/something/my_option|/something/myOption| -### account subscription-operation show - -show a account subscription-operation. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| \ No newline at end of file +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az account|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az account` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az account subscription|Subscriptions|[commands](#CommandsInSubscriptions)| +|az account tenant|Tenants|[commands](#CommandsInTenants)| +|az account subscription|Subscription|[commands](#CommandsInSubscription)| +|az account alias|Alias|[commands](#CommandsInAlias)| + +## COMMANDS +### Commands in `az account alias` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az account alias list](#AliasList)|List|[Parameters](#ParametersAliasList)|[Example](#ExamplesAliasList)| +|[az account alias show](#AliasGet)|Get|[Parameters](#ParametersAliasGet)|[Example](#ExamplesAliasGet)| +|[az account alias create](#AliasCreate)|Create|[Parameters](#ParametersAliasCreate)|[Example](#ExamplesAliasCreate)| +|[az account alias delete](#AliasDelete)|Delete|[Parameters](#ParametersAliasDelete)|[Example](#ExamplesAliasDelete)| + +### Commands in `az account subscription` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az account subscription list](#SubscriptionsList)|List|[Parameters](#ParametersSubscriptionsList)|[Example](#ExamplesSubscriptionsList)| +|[az account subscription show](#SubscriptionsGet)|Get|[Parameters](#ParametersSubscriptionsGet)|[Example](#ExamplesSubscriptionsGet)| +|[az account subscription list-location](#SubscriptionsListLocations)|ListLocations|[Parameters](#ParametersSubscriptionsListLocations)|[Example](#ExamplesSubscriptionsListLocations)| + +### Commands in `az account subscription` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az account subscription cancel](#SubscriptionCancel)|Cancel|[Parameters](#ParametersSubscriptionCancel)|[Example](#ExamplesSubscriptionCancel)| +|[az account subscription enable](#SubscriptionEnable)|Enable|[Parameters](#ParametersSubscriptionEnable)|[Example](#ExamplesSubscriptionEnable)| +|[az account subscription rename](#SubscriptionRename)|Rename|[Parameters](#ParametersSubscriptionRename)|[Example](#ExamplesSubscriptionRename)| + +### Commands in `az account tenant` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az account tenant list](#TenantsList)|List|[Parameters](#ParametersTenantsList)|[Example](#ExamplesTenantsList)| + + +## COMMAND DETAILS + +### group `az account alias` +#### Command `az account alias list` + +##### Example +``` +az account alias list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az account alias show` + +##### Example +``` +az account alias show --name "aliasForNewSub" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| + +#### Command `az account alias create` + +##### Example +``` +az account alias create --name "aliasForNewSub" --properties billing-scope="/providers/Microsoft.Billing/billingAccount\ +s/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG7-TG\ +B/invoiceSections/MTT4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload="Production" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| +|**--properties**|object|Put alias request properties.|properties|properties| + +#### Command `az account alias delete` + +##### Example +``` +az account alias delete --name "aliasForNewSub" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| + +### group `az account subscription` +#### Command `az account subscription list` + +##### Example +``` +az account subscription list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az account subscription show` + +##### Example +``` +az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id|subscriptionId| + +#### Command `az account subscription list-location` + +##### Example +``` +az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id|subscriptionId| + +### group `az account subscription` +#### Command `az account subscription cancel` + +##### Example +``` +az account subscription cancel --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Subscription Id.|subscription_id|subscriptionId| + +#### Command `az account subscription enable` + +##### Example +``` +az account subscription enable --subscription-id "7948bcee-488c-47ce-941c-38e20ede803d" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Subscription Id.|subscription_id|subscriptionId| + +#### Command `az account subscription rename` + +##### Example +``` +az account subscription rename --name "Test Sub" --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Subscription Id.|subscription_id|subscriptionId| +|**--subscription-name**|string|New subscription name|subscription_name|subscriptionName| + +### group `az account tenant` +#### Command `az account tenant list` + +##### Example +``` +az account tenant list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| \ No newline at end of file diff --git a/src/account/setup.cfg b/src/account/setup.cfg index e69de29bb2d..2fdd96e5d39 100644 --- a/src/account/setup.cfg +++ b/src/account/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/account/setup.py b/src/account/setup.py index 76f518859ef..a24d9eb1de9 100644 --- a/src/account/setup.py +++ b/src/account/setup.py @@ -8,15 +8,13 @@ from codecs import open from setuptools import setup, find_packages -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - logger.warn("Wheel is not available, disabling bdist_wheel hook") -# TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '0.2.1' +VERSION = '0.1.0' +try: + from azext_account.manual.version import VERSION +except ImportError: + pass # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -32,10 +30,14 @@ 'License :: OSI Approved :: MIT License', ] -# TODO: Add any additional SDK dependencies here DEPENDENCIES = [] -with open('README.rst', 'r', encoding='utf-8') as f: +try: + from azext_account.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() @@ -44,7 +46,6 @@ name='account', version=VERSION, description='Microsoft Azure Command-Line Tools SubscriptionClient Extension', - # TODO: Update author and email, if applicable author='Microsoft Corporation', author_email='azpycli@microsoft.com', url='https://github.com/Azure/azure-cli-extensions/tree/master/src/account',