From 3ee5dae399614613d031ed64e493f93c6a5808a0 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 2 Oct 2020 19:18:49 +0000 Subject: [PATCH] Generated from 2174f01d50fead9cd9fe3fa9d193714217c9ce4a --- src/account/HISTORY.rst | 7 - src/account/{README.rst => README.md} | 0 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 | 30 ++- src/account/azext_account/generated/_help.py | 115 ++++---- .../azext_account/generated/_params.py | 65 ++--- .../azext_account/generated/_validators.py | 23 +- src/account/azext_account/generated/action.py | 44 ++++ .../azext_account/generated/commands.py | 37 ++- src/account/azext_account/generated/custom.py | 56 ++-- .../version.py => manual/__init__.py} | 3 +- src/account/azext_account/tests/__init__.py | 114 ++++++++ .../azext_account/tests/latest/__init__.py | 12 + .../tests/latest/test_account_scenario.py | 216 +++++++++------ .../subscription/_subscription_client.py | 5 + .../aio/_subscription_client_async.py | 5 + .../aio/operations_async/__init__.py | 2 + .../_subscription_operations_async.py | 194 +------------- .../subscription/models/_models.py | 21 +- .../subscription/models/_models_py3.py | 22 +- .../subscription/operations/__init__.py | 2 + .../subscription/operations/_operations.py | 89 ------- .../_subscription_operation_operations.py | 104 -------- .../operations/_subscription_operations.py | 196 +------------- src/account/report.md | 248 ++++++++++++++---- src/account/setup.cfg | 3 +- src/account/setup.py | 23 +- 32 files changed, 797 insertions(+), 913 deletions(-) rename src/account/{README.rst => README.md} (100%) 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 delete mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_operations.py delete mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py diff --git a/src/account/HISTORY.rst b/src/account/HISTORY.rst index f609ea48b2d..1c139576ba0 100644 --- a/src/account/HISTORY.rst +++ b/src/account/HISTORY.rst @@ -3,13 +3,6 @@ Release History =============== -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.rst b/src/account/README.md similarity index 100% rename from src/account/README.rst rename to src/account/README.md 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..4f48fa652a5 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.11.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..bf2d02be86f 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 +def cf_account_cl(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] + 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).subscription def cf_tenant(cli_ctx, *_): - return cf_account(cli_ctx).tenant + return cf_account_cl(cli_ctx).tenant + + +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..74e50b15ec0 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: account subscription """ -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: account tenant +""" + +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: account subscription +""" + +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: account alias """ 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 03eba5b0461..cf156923dca 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -1,57 +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('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..c871f7990eb --- /dev/null +++ b/src/account/azext_account/generated/action.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------- +# 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] + return d diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index 24fcc3ed2e4..fbcf5204541 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,12 +17,11 @@ 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._subscription_operations#SubscriptionOpera' + 'tions.{}', 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, + is_experimental=True) 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') @@ -31,6 +33,17 @@ def load_command_table(self, _): with self.command_group('account tenant', account_tenant, client_factory=cf_tenant, is_experimental=True) 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, + is_experimental=True) 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.{}', @@ -39,5 +52,5 @@ def load_command_table(self, _): 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') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 96e94c240c4..ce006c0552c 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() @@ -42,6 +30,23 @@ 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): + return client.rename(subscription_id=subscription_id, + subscription_name=subscription_name) + + def account_alias_list(client): return client.list() @@ -53,17 +58,8 @@ def account_alias_show(client, def account_alias_create(client, alias_name, - workload=None, - billing_scope=None, - display_name=None, - subscription_id=None, + properties, no_wait=False): - properties = { - 'display_name': display_name, - 'workload': workload, - 'billing_scope': billing_scope, - 'subscription_id': subscription_id - } return sdk_no_wait(no_wait, client.begin_create, alias_name=alias_name, 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..50e0627daff --- /dev/null +++ b/src/account/azext_account/tests/__init__.py @@ -0,0 +1,114 @@ +# 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) + module_path = __path__[0] + 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) + 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: + 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/test_account_scenario.py b/src/account/azext_account/tests/latest/test_account_scenario.py index f00a99d5c5b..7a25925862b 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -1,92 +1,152 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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 .. import try_manual, raise_if, calc_coverage TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) +@try_manual +def setup(test): + pass + + +# EXAMPLE: /Alias/put/CreateAlias +@try_manual +def step__alias_put_createalias(test): + 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=[ + test.check("name", "{myAlias}", case_sensitive=False), + ]) + + +# EXAMPLE: /Alias/get/GetAlias +@try_manual +def step__alias_get_getalias(test): + test.cmd('az account alias list', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Alias/get/GetAlias +@try_manual +def step__alias_get_getalias(test): + test.cmd('az account alias list', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Subscriptions/get/getSubscription +@try_manual +def step__subscriptions_get_getsubscription(test): + test.cmd('az account subscription show ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscriptions/get/listLocations +@try_manual +def step__subscriptions_get_listlocations(test): + test.cmd('az account subscription list-location ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscriptions/get/listSubscriptions +@try_manual +def step__subscriptions_get_listsubscriptions(test): + test.cmd('az account subscription list', + checks=[]) + + +# EXAMPLE: /Subscription/post/cancelSubscription +@try_manual +def step__subscription_post_cancelsubscription(test): + test.cmd('az account subscription cancel ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscription/post/enableSubscription +@try_manual +def step__subscription_post_enablesubscription(test): + test.cmd('az account subscription enable ' + '--subscription-id "7948bcee-488c-47ce-941c-38e20ede803d"', + checks=[]) + + +# EXAMPLE: /Subscription/post/renameSubscription +@try_manual +def step__subscription_post_renamesubscription(test): + test.cmd('az account subscription rename ' + '--name "{mySubscription}" ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Tenants/get/listTenants +@try_manual +def step__tenants_get_listtenants(test): + test.cmd('az account tenant list', + checks=[]) + + +# EXAMPLE: /Alias/delete/DeleteAlias +@try_manual +def step__alias_delete_deletealias(test): + test.cmd('az account alias delete -y ' + '--name "{myAlias}"', + checks=[]) + + +@try_manual +def cleanup(test): + pass + + +@try_manual +def call_scenario(test): + setup(test) + step__alias_put_createalias(test) + step__alias_get_getalias(test) + step__alias_get_getalias(test) + step__subscriptions_get_getsubscription(test) + step__subscriptions_get_listlocations(test) + step__subscriptions_get_listsubscriptions(test) + step__subscription_post_cancelsubscription(test) + step__subscription_post_enablesubscription(test) + step__subscription_post_renamesubscription(test) + step__tenants_get_listtenants(test) + step__alias_delete_deletealias(test) + cleanup(test) + + +@try_manual class SubscriptionClientScenarioTest(ScenarioTest): - # @ResourceGroupPreparer(name_prefix='cli_test_account') def test_account(self): + 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" + 'mySubscription': 'Test Sub', + 'myAlias': 'aliasForNewSub', }) - self.cmd('az account alias create --name {alias_name} --billing-scope "{billing_scope}" --display-name "{display_name}" --workload "Production"', - 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}) - - # response different from swagger, causing deserialization error - # self.cmd('az account alias list', - # checks=[]) - - 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) - self.cmd('az account subscription show --subscription-id {subscription_id}', - checks=[self.check('displayName', '{display_name}'), - self.check('state', 'Warned'), - self.check('subscriptionId', sub_id)]) - - self.cmd('az account subscription enable --subscription-id {subscription_id}', - checks=[self.check('subscriptionId', '{subscription_id}')]) - time.sleep(300) - 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 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')]) - - time.sleep(600) - self.cmd('az account alias delete -n {new_alias_name}', - checks=[]) + call_scenario(self) + calc_coverage(__file__) + raise_if() 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..f07f6a8594a 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py +++ b/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py @@ -20,6 +20,7 @@ from ._configuration import SubscriptionClientConfiguration from .operations import SubscriptionOperations from .operations import TenantOperations +from .operations import SubscriptionOperations from .operations import OperationOperations from .operations import AliasOperations from . import models @@ -32,6 +33,8 @@ class SubscriptionClient(object): :vartype subscription: subscription_client.operations.SubscriptionOperations :ivar tenant: TenantOperations operations :vartype tenant: subscription_client.operations.TenantOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.operations.SubscriptionOperations :ivar operation: OperationOperations operations :vartype operation: subscription_client.operations.OperationOperations :ivar alias: AliasOperations operations @@ -62,6 +65,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.tenant = TenantOperations( self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) self.operation = OperationOperations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( 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_async.py index 92ce5f10d73..a024387c173 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_async.py @@ -18,6 +18,7 @@ from ._configuration_async import SubscriptionClientConfiguration from .operations_async import SubscriptionOperations from .operations_async import TenantOperations +from .operations_async import SubscriptionOperations from .operations_async import OperationOperations from .operations_async import AliasOperations from .. import models @@ -30,6 +31,8 @@ class SubscriptionClient(object): :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations :ivar tenant: TenantOperations operations :vartype tenant: subscription_client.aio.operations_async.TenantOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations :ivar operation: OperationOperations operations :vartype operation: subscription_client.aio.operations_async.OperationOperations :ivar alias: AliasOperations operations @@ -59,6 +62,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.tenant = TenantOperations( self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) self.operation = OperationOperations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( 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_async/__init__.py index 7aac3e6b7f8..13b77eb8918 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py @@ -8,12 +8,14 @@ from ._subscription_operations_async import SubscriptionOperations from ._tenant_operations_async import TenantOperations +from ._subscription_operations_async import SubscriptionOperations from ._operation_operations_async import OperationOperations from ._alias_operations_async import AliasOperations __all__ = [ 'SubscriptionOperations', 'TenantOperations', + 'SubscriptionOperations', 'OperationOperations', 'AliasOperations', ] 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_async/_subscription_operations_async.py index 287209147a0..e957c867bf0 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_async/_subscription_operations_async.py @@ -5,10 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest @@ -41,184 +40,6 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list_location( - self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["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.async_paging.AsyncItemPaged[~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 - - async 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, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_location.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - async def get( - self, - subscription_id: str, - **kwargs - ) -> "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 = 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) - 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 - ) -> AsyncIterable["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.async_paging.AsyncItemPaged[~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 - - async 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, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore - async def cancel( self, subscription_id: str, @@ -382,3 +203,16 @@ async def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore +eline_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore 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 5987788aaf3..7e2e60058b6 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -303,19 +303,18 @@ 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". + :param workload: 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 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. :type subscription_id: str + :param reseller_id: Reseller ID, basically MPN Id. + :type reseller_id: str """ _attribute_map = { @@ -323,6 +322,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): 'workload': {'key': 'workload', 'type': 'str'}, 'billing_scope': {'key': 'billingScope', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, } def __init__( @@ -330,10 +330,11 @@ def __init__( **kwargs ): super(PutAliasRequestProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.workload = kwargs['workload'] - self.billing_scope = kwargs['billing_scope'] + self.display_name = kwargs.get('display_name', None) + self.workload = kwargs.get('workload', None) + self.billing_scope = kwargs.get('billing_scope', None) self.subscription_id = kwargs.get('subscription_id', None) + self.reseller_id = kwargs.get('reseller_id', None) class PutAliasResponse(msrest.serialization.Model): 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 5f0dee7a2cb..7067cd918ee 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 @@ -326,19 +326,18 @@ 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". + :param workload: 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 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. :type subscription_id: str + :param reseller_id: Reseller ID, basically MPN Id. + :type reseller_id: str """ _attribute_map = { @@ -346,15 +345,17 @@ class PutAliasRequestProperties(msrest.serialization.Model): 'workload': {'key': 'workload', 'type': 'str'}, 'billing_scope': {'key': 'billingScope', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, } def __init__( self, *, - display_name: str, - workload: Union[str, "Workload"], - billing_scope: str, + display_name: Optional[str] = None, + workload: Optional[Union[str, "Workload"]] = None, + billing_scope: Optional[str] = None, subscription_id: Optional[str] = None, + reseller_id: Optional[str] = None, **kwargs ): super(PutAliasRequestProperties, self).__init__(**kwargs) @@ -362,6 +363,7 @@ def __init__( self.workload = workload self.billing_scope = billing_scope self.subscription_id = subscription_id + self.reseller_id = reseller_id class PutAliasResponse(msrest.serialization.Model): 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..f6227cb943f 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py @@ -8,12 +8,14 @@ from ._subscription_operations import SubscriptionOperations from ._tenant_operations import TenantOperations +from ._subscription_operations import SubscriptionOperations from ._operation_operations import OperationOperations from ._alias_operations import AliasOperations __all__ = [ 'SubscriptionOperations', 'TenantOperations', + 'SubscriptionOperations', 'OperationOperations', 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py deleted file mode 100644 index 664844824d5..00000000000 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py +++ /dev/null @@ -1,89 +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 .. import models - - -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. - - :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 list( - self, custom_headers=None, raw=False, **operation_config): - """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` - """ - # Construct URL - url = self.list.metadata['url'] - - # 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]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationListResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} 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..f0395328c7d 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 @@ -9,7 +9,6 @@ import warnings from azure.core.exceptions import 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 @@ -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]] @@ -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 @@ -392,3 +210,15 @@ def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore +nse = 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/report.md b/src/account/report.md index dbffaf42067..f69c55f7fd4 100644 --- a/src/account/report.md +++ b/src/account/report.md @@ -1,75 +1,209 @@ # Azure CLI Module Creation Report -### account operation list +### account alias create -list a account operation. +create a account alias. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account alias|Alias| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| +|**--properties**|object|Put alias request properties.|properties|properties| + +### account alias delete + +delete a account alias. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account alias|Alias| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|delete|Delete| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| + +### account alias list + +list a account alias. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account alias|Alias| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| + +### account alias show + +show a account alias. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account alias|Alias| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--alias-name**|string|Alias Name|alias_name|aliasName| -|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| +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscription| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|cancel|Cancel| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Subscription Id.|subscription_id|subscriptionId| + ### account subscription enable enable a account subscription. -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscription| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|enable|Enable| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Subscription Id.|subscription_id|subscriptionId| + +### account subscription list + +list a account subscription. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscriptions| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| + +### account subscription list-location + +list-location a account subscription. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscriptions| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list-location|ListLocations| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id|subscriptionId| + ### 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 +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscription| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|rename|Rename| + +#### 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| + +### account subscription show + +show a account subscription. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account subscription|Subscriptions| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id|subscriptionId| + +### account tenant list + +list a account tenant. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|account tenant|Tenants| -show a account subscription-operation. +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| \ No newline at end of file +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| diff --git a/src/account/setup.cfg b/src/account/setup.cfg index 3c6e79cf31d..2fdd96e5d39 100644 --- a/src/account/setup.cfg +++ b/src/account/setup.cfg @@ -1,2 +1 @@ -[bdist_wheel] -universal=1 +#setup.cfg \ No newline at end of file diff --git a/src/account/setup.py b/src/account/setup.py index 721b72f13be..780591faa6e 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.0' +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,13 @@ 'License :: OSI Approved :: MIT License', ] -# TODO: Add any additional SDK dependencies here DEPENDENCIES = [] +try: + from .manual.dependency import DEPENDENCIES +except ImportError: + pass -with open('README.rst', 'r', encoding='utf-8') as f: +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,11 +45,9 @@ 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', - # TODO: consider pointing directly to your source code instead of the generic repo - url='https://github.com/Azure/azure-cli-extensions', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/account', long_description=README + '\n\n' + HISTORY, license='MIT', classifiers=CLASSIFIERS,