From db481f25bc34916a8d0225d756d603707dc1baa2 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Thu, 3 Sep 2020 09:41:33 +0800 Subject: [PATCH 01/12] add alias and tenant commands --- .../generated/_client_factory.py | 14 +- src/account/azext_account/generated/_help.py | 134 ++++++++++++----- .../azext_account/generated/_params.py | 56 +++---- src/account/azext_account/generated/action.py | 34 +++++ .../azext_account/generated/commands.py | 27 +++- src/account/azext_account/generated/custom.py | 142 ++++++++++++------ 6 files changed, 288 insertions(+), 119 deletions(-) diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index 09cec837dcf..5e9570852cd 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -15,10 +15,16 @@ def cf_account(cli_ctx, *_): def cf_subscription(cli_ctx, *_): return cf_account(cli_ctx).subscription +# def cf_subscription_operation(cli_ctx, *_): +# return cf_account(cli_ctx).subscription_operation -def cf_subscription_operation(cli_ctx, *_): - return cf_account(cli_ctx).subscription_operation +# def cf_operation(cli_ctx, *_): +# return cf_account(cli_ctx).operation -def cf_operation(cli_ctx, *_): - return cf_account(cli_ctx).operation +def cf_tenant(cli_ctx, *_): + return cf_account(cli_ctx).tenant + + +def cf_alias(cli_ctx, *_): + return cf_account(cli_ctx).alias diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 3a23cb4c683..ced8f63e8e1 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -13,68 +13,132 @@ short-summary: Manage subscriptions """ -helps['account subscription create'] = """ +helps['account subscription rename'] = """ type: command - short-summary: Create a new WebDirect or EA Azure subscription. + short-summary: Rename subscription examples: - - name: Create subscription + - name: Rename subscription text: |- - az account subscription create --billing-account-name \\ - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_XXXX-XX-XX" \\ - --billing-profile-name "27VR-HDWX-BG7-TGB" --cost-center "135366376" --display-name \\ - "Contoso MCA subscription" --owner xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\ - --sku-id "0001" --invoice-section-name "JGF7-NSBG-PJA-TGB" + az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" """ +helps['account subscription cancel'] = """ + type: command + short-summary: Cancel subscription + examples: + - name: Cancel subscription + text: |- + az account subscription cancel --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +""" -helps['account subscription create-in-enrollment-account'] = """ +helps['account subscription enable'] = """ type: command - short-summary: Create subscription in enrolment account + short-summary: Enable subscription examples: - - name: Create subscription in enrollment account + - name: Enable subscription text: |- - az account subscription create-in-enrollment-account --display-name \\ - "Test Ea Azure Sub" --offer-type "MS-AZR-0017P" --owners \\ - xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\ - xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --enrollment-account-name \\ - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" """ -helps['account subscription create-csp'] = """ +helps['account subscription list'] = """ type: command - short-summary: Create a new CSP subscription. + short-summary: Gets all subscriptions for a tenant. examples: - - name: Create CSP subscription + - name: listSubscriptions text: |- - az account subscription create-csp --billing-account-name \\ - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_XXXX-XX-XX" \\ - --display-name "Contoso MCA subscription" --sku-id "0001" --customer-name \\ - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription list """ -helps['account subscription rename'] = """ +helps['account subscription show'] = """ type: command - short-summary: Rename subscription + short-summary: Gets details about a specified subscription. examples: - - name: Rename subscription + - name: getSubscription text: |- - az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" """ -helps['account subscription cancel'] = """ +helps['account subscription list-location'] = """ type: command - short-summary: Cancel subscription + 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. examples: - - name: Cancel subscription + - name: listLocations text: |- - az account subscription cancel --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" """ -helps['account subscription enable'] = """ +helps['account tenant'] = """ + type: group + short-summary: account tenant +""" + +helps['account tenant list'] = """ type: command - short-summary: Enable subscription + short-summary: Gets the tenants for your account. examples: - - name: Enable subscription + - name: listTenants text: |- - az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + az account tenant list +""" + +helps['account alias'] = """ + type: group + short-summary: account alias +""" + +helps['account alias list'] = """ + type: command + short-summary: List Alias Subscriptions. + examples: + - name: List Alias Subscriptions + text: |- + az account alias list +""" + +helps['account alias show'] = """ + type: command + short-summary: Get Alias Subscription. + examples: + - name: GetAlias + text: |- + az account alias show --name "aliasForNewSub" +""" + +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 + display-name: Required. The friendly name of the subscription. + workload: Required. The workload type of the subscription. It can be either Production or DevTest. + billing-scope: Required. Determines whether subscription is fieldLed, partnerLed or LegacyEA + subscription-id: This parameter can be used to create alias for existing subscription Id + examples: + - name: CreateAlias + text: |- + 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. + examples: + - name: DeleteAlias + text: |- + az account alias delete --name "aliasForNewSub" +""" + +helps['account alias wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the account alias is met. + examples: + - name: Pause executing next line of CLI script until the account alias is successfully created. + text: |- + az account alias wait --name "aliasForNewSub" --created """ diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index 2f43fd76d28..e46405ebdd0 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -6,37 +6,11 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from azure.cli.core.commands.parameters import ( - get_enum_type -) +from azext_account.action import AddProperties def load_arguments(self, _): - with self.argument_context('account subscription create') as c: - c.argument('billing_account_name', help='The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.') - c.argument('billing_profile_name', help='The name of the billing profile in the billing account for which you want to create the subscription.') - c.argument('invoice_section_name', help='The name of the invoice section in the billing account for which you want to create the subscription.') - c.argument('display_name', help='The friendly name of the subscription.') - c.argument('sku_id', help='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.') - c.argument('cost_center', help='If set, the cost center will show up on the Azure usage and charges file.') - c.argument('owner', help='Active Directory Principal who’ll get owner access on the new subscription.') - c.argument('management_group_id', help='The identifier of the management group to which this subscription will be associated.') - - with self.argument_context('account subscription create-in-enrollment-account') as c: - c.argument('enrollment_account_name', help='The name of the enrollment account to which the subscription will be billed.') - c.argument('display_name', help='The display name of the subscription.') - c.argument('management_group_id', help='The Management Group Id.') - c.argument('owners', nargs='+', help='The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.') - c.argument('offer_type', arg_type=get_enum_type(['MS-AZR-0017P', 'MS-AZR-0148P']), help='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.') - - with self.argument_context('account subscription create-csp') as c: - c.argument('billing_account_name', help='The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.') - c.argument('customer_name', help='The name of the customer.') - c.argument('display_name', help='The friendly name of the subscription.') - c.argument('sku_id', help='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.') - c.argument('reseller_id', help='Reseller ID, basically MPN Id.') - with self.argument_context('account subscription rename') as c: c.argument('subscription_id', help='Subscription Id.') c.argument('subscription_name', help='New subscription name') @@ -46,3 +20,31 @@ def load_arguments(self, _): with self.argument_context('account subscription enable') as c: c.argument('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', help='The ID of the target subscription.', id_part='subscription') + + with self.argument_context('account subscription list-location') as c: + c.argument('subscription_id', help='The ID of the target subscription.') + + with self.argument_context('account tenant list') as c: + pass + + with self.argument_context('account alias list') as c: + pass + + 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') as c: + c.argument('alias_name', options_list=['--name', '-n'], 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') + + with self.argument_context('account alias wait') as c: + c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') diff --git a/src/account/azext_account/generated/action.py b/src/account/azext_account/generated/action.py index 34913fb394d..0d4cd4ef8af 100644 --- a/src/account/azext_account/generated/action.py +++ b/src/account/azext_account/generated/action.py @@ -2,3 +2,37 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +# 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] + return d diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index 4cd99d42525..2e350cd0e3d 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -17,9 +17,30 @@ def load_command_table(self, _): operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}', client_factory=cf_subscription) with self.command_group('account subscription', account_subscription, client_factory=cf_subscription) as g: - g.custom_command('create', 'account_subscription_create_subscription', supports_no_wait=True) + # g.custom_command('create', 'account_subscription_create_subscription', supports_no_wait=True) g.custom_command('rename', 'account_subscription_rename') g.custom_command('cancel', 'account_subscription_cancel', confirmation=True) g.custom_command('enable', 'account_subscription_enable') - g.custom_command('create-csp', 'account_subscription_create_csp_subscription', supports_no_wait=True) - g.custom_command('create-in-enrollment-account', 'account_subscription_create_subscription_in_enrollment_account', supports_no_wait=True) + # g.custom_command('create-csp', 'account_subscription_create_csp_subscription', supports_no_wait=True) + # g.custom_command('create-in-enrollment-account', 'account_subscription_create_subscription_in_enrollment_account', supports_no_wait=True) + g.custom_command('list', 'account_subscription_list') + g.custom_show_command('show', 'account_subscription_show') + g.custom_command('list-location', 'account_subscription_list_location') + + from azext_account.generated._client_factory import cf_tenant + account_tenant = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._tenant_operations#TenantOperations.{}', + client_factory=cf_tenant) + 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_alias + account_alias = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._alias_operations#AliasOperations.{}', + client_factory=cf_alias) + with self.command_group('account alias', account_alias, client_factory=cf_alias, is_experimental=True) as g: + 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_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 ccdcccb94f1..0b7dd4b47ec 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -11,56 +11,56 @@ from azure.cli.core.util import sdk_no_wait -def account_subscription_create_subscription(cmd, client, - billing_account_name, - billing_profile_name, - invoice_section_name, - display_name, - sku_id, - cost_center=None, - owner=None, - management_group_id=None, - no_wait=False): - - body = {} - body['display_name'] = display_name - body['sku_id'] = sku_id - body['cost_center'] = cost_center - body['owner'] = {'object_id': owner} - body['management_group_id'] = management_group_id - return sdk_no_wait(no_wait, client.create_subscription, billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, body=body) - - -def account_subscription_create_subscription_in_enrollment_account(cmd, client, - enrollment_account_name, - display_name=None, - management_group_id=None, - owners=None, - offer_type=None, - no_wait=False): - if owners is not None: - owners = [{'object_id': x} for x in owners] - - body = {} - body['display_name'] = display_name - body['management_group_id'] = management_group_id - body['owners'] = owners - body['offer_type'] = offer_type - return sdk_no_wait(no_wait, client.create_subscription_in_enrollment_account, enrollment_account_name=enrollment_account_name, body=body) - - -def account_subscription_create_csp_subscription(cmd, client, - billing_account_name, - customer_name, - display_name, - sku_id, - reseller_id=None, - no_wait=False): - body = {} - body['display_name'] = display_name - body['sku_id'] = sku_id - body['reseller_id'] = reseller_id - return sdk_no_wait(no_wait, client.create_csp_subscription, billing_account_name=billing_account_name, customer_name=customer_name, body=body) +# def account_subscription_create_subscription(cmd, client, +# billing_account_name, +# billing_profile_name, +# invoice_section_name, +# display_name, +# sku_id, +# cost_center=None, +# owner=None, +# management_group_id=None, +# no_wait=False): + +# body = {} +# body['display_name'] = display_name +# body['sku_id'] = sku_id +# body['cost_center'] = cost_center +# body['owner'] = {'object_id': owner} +# body['management_group_id'] = management_group_id +# return sdk_no_wait(no_wait, client.create_subscription, billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, body=body) + + +# def account_subscription_create_subscription_in_enrollment_account(cmd, client, +# enrollment_account_name, +# display_name=None, +# management_group_id=None, +# owners=None, +# offer_type=None, +# no_wait=False): +# if owners is not None: +# owners = [{'object_id': x} for x in owners] + +# body = {} +# body['display_name'] = display_name +# body['management_group_id'] = management_group_id +# body['owners'] = owners +# body['offer_type'] = offer_type +# return sdk_no_wait(no_wait, client.create_subscription_in_enrollment_account, enrollment_account_name=enrollment_account_name, body=body) + + +# def account_subscription_create_csp_subscription(cmd, client, +# billing_account_name, +# customer_name, +# display_name, +# sku_id, +# reseller_id=None, +# no_wait=False): +# body = {} +# body['display_name'] = display_name +# body['sku_id'] = sku_id +# body['reseller_id'] = reseller_id +# return sdk_no_wait(no_wait, client.create_csp_subscription, billing_account_name=billing_account_name, customer_name=customer_name, body=body) def account_subscription_rename(cmd, client, subscription_id, @@ -74,3 +74,45 @@ def account_subscription_cancel(cmd, client, 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() + + +def account_subscription_show(client, + subscription_id): + return client.get(subscription_id=subscription_id) + + +def account_subscription_list_location(client, + subscription_id): + return client.list_location(subscription_id=subscription_id) + + +def account_tenant_list(client): + return client.list() + + +def account_alias_list(client): + return client.list() + + +def account_alias_show(client, + alias_name): + return client.get(alias_name=alias_name) + + +def account_alias_create(client, + alias_name, + properties, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create, + alias_name=alias_name, + properties=properties) + + +def account_alias_delete(client, + alias_name): + return client.delete(alias_name=alias_name) From 65bff0c555fb5f0311ecd25d1e78c2fe5734adaf Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Thu, 3 Sep 2020 16:01:08 +0800 Subject: [PATCH 02/12] new sdk --- .../azext_account/vendored_sdks/__init__.py | 2 +- .../vendored_sdks/subscription/__init__.py | 19 +- .../subscription/_configuration.py | 77 +- .../subscription/_subscription_client.py | 92 ++- .../subscription/aio/__init__.py | 10 + .../subscription/aio/_configuration_async.py | 58 ++ .../aio/_subscription_client_async.py | 75 ++ .../aio/operations_async/__init__.py | 19 + .../_alias_operations_async.py | 295 ++++++++ .../_operation_operations_async.py | 86 +++ .../_subscription_operations_async.py | 387 ++++++++++ .../_tenant_operations_async.py | 101 +++ .../subscription/models/__init__.py | 92 ++- .../subscription/models/_models.py | 633 +++++++++++----- .../subscription/models/_models_py3.py | 674 ++++++++++++----- .../models/_subscription_client_enums.py | 40 +- .../subscription/operations/__init__.py | 17 +- .../operations/_alias_operations.py | 304 ++++++++ .../operations/_operation_operations.py | 91 +++ .../operations/_subscription_operations.py | 708 +++++++----------- .../operations/_tenant_operations.py | 106 +++ .../vendored_sdks/subscription/py.typed | 1 + 22 files changed, 2972 insertions(+), 915 deletions(-) create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/__init__.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/py.typed diff --git a/src/account/azext_account/vendored_sdks/__init__.py b/src/account/azext_account/vendored_sdks/__init__.py index be1a152630c..c9cfdc73e77 100644 --- a/src/account/azext_account/vendored_sdks/__init__.py +++ b/src/account/azext_account/vendored_sdks/__init__.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/vendored_sdks/subscription/__init__.py b/src/account/azext_account/vendored_sdks/subscription/__init__.py index 399e93fb102..b07b0882922 100644 --- a/src/account/azext_account/vendored_sdks/subscription/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/src/account/azext_account/vendored_sdks/subscription/_configuration.py b/src/account/azext_account/vendored_sdks/subscription/_configuration.py index ad45d175c06..e3e69420927 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_configuration.py +++ b/src/account/azext_account/vendored_sdks/subscription/_configuration.py @@ -1,43 +1,62 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-subscription/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(SubscriptionClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'subscriptionclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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 cda5db6c15b..d06f83460ca 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py +++ b/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py @@ -1,57 +1,81 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential from ._configuration import SubscriptionClientConfiguration from .operations import SubscriptionOperations -from .operations import SubscriptionOperationOperations -from .operations import Operations +from .operations import TenantOperations +from .operations import OperationOperations +from .operations import AliasOperations from . import models -class SubscriptionClient(SDKClient): - """The subscription client - - :ivar config: Configuration for client. - :vartype config: SubscriptionClientConfiguration - - :ivar subscription: Subscription operations - :vartype subscription: azure.mgmt.subscription.operations.SubscriptionOperations - :ivar subscription_operation: SubscriptionOperation operations - :vartype subscription_operation: azure.mgmt.subscription.operations.SubscriptionOperationOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.subscription.operations.Operations +class SubscriptionClient(object): + """The subscription client. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.operations.SubscriptionOperations + :ivar tenant: TenantOperations operations + :vartype tenant: subscription_client.operations.TenantOperations + :ivar operation: OperationOperations operations + :vartype operation: subscription_client.operations.OperationOperations + :ivar alias: AliasOperations operations + :vartype alias: subscription_client.operations.AliasOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credentials, base_url=None): - - self.config = SubscriptionClientConfiguration(credentials, base_url) - super(SubscriptionClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-10-01-preview' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.subscription = SubscriptionOperations( - self._client, self.config, self._serialize, self._deserialize) - self.subscription_operation = SubscriptionOperationOperations( - self._client, self.config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.tenant = TenantOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SubscriptionClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py b/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py new file mode 100644 index 00000000000..345034cd293 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_client_async import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py new file mode 100644 index 00000000000..d671822a671 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(SubscriptionClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'subscriptionclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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 new file mode 100644 index 00000000000..92ce5f10d73 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration_async import SubscriptionClientConfiguration +from .operations_async import SubscriptionOperations +from .operations_async import TenantOperations +from .operations_async import OperationOperations +from .operations_async import AliasOperations +from .. import models + + +class SubscriptionClient(object): + """The subscription client. + + :ivar subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations + :ivar tenant: TenantOperations operations + :vartype tenant: subscription_client.aio.operations_async.TenantOperations + :ivar operation: OperationOperations operations + :vartype operation: subscription_client.aio.operations_async.OperationOperations + :ivar alias: AliasOperations operations + :vartype alias: subscription_client.aio.operations_async.AliasOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant = TenantOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SubscriptionClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 00000000000..7aac3e6b7f8 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_operations_async import SubscriptionOperations +from ._tenant_operations_async import TenantOperations +from ._operation_operations_async import OperationOperations +from ._alias_operations_async import AliasOperations + +__all__ = [ + 'SubscriptionOperations', + 'TenantOperations', + 'OperationOperations', + 'AliasOperations', +] diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py new file mode 100644 index 00000000000..d5e817b84b3 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py @@ -0,0 +1,295 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AliasOperations: + """AliasOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + alias_name: str, + properties: "models.PutAliasRequestProperties", + **kwargs + ) -> "models.PutAliasResponse": + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.PutAliasRequest(properties=properties) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def create( + self, + alias_name: str, + properties: "models.PutAliasRequestProperties", + **kwargs + ) -> "models.PutAliasResponse": + """Create Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def get( + self, + alias_name: str, + **kwargs + ) -> "models.PutAliasResponse": + """Get Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def delete( + self, + alias_name: str, + **kwargs + ) -> None: + """Delete Alias. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def list( + self, + **kwargs + ) -> "models.PutAliasListResult": + """Get Alias Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasListResult, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..dc4efebc375 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list( + self, + **kwargs + ) -> "models.OperationListResult": + """Lists all of the available Microsoft.Subscription API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult, or the result of cls(response) + :rtype: ~subscription_client.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py new file mode 100644 index 00000000000..97d2463fd20 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py @@ -0,0 +1,387 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionOperations: + """SubscriptionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_location( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + + Gets all available geo-locations. + + :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): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + 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' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + 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): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + 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, + **kwargs + ) -> "models.CanceledSubscriptionId": + """The operation to cancel a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CanceledSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.CanceledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.cancel.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + + async def rename( + self, + subscription_id: str, + subscription_name: Optional[str] = None, + **kwargs + ) -> "models.RenamedSubscriptionId": + """The operation to rename a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param subscription_name: New subscription name. + :type subscription_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RenamedSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.RenamedSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.SubscriptionName(subscription_name=subscription_name) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.rename.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'SubscriptionName') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + + async def enable( + self, + subscription_id: str, + **kwargs + ) -> "models.EnabledSubscriptionId": + """The operation to enable a subscription. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnabledSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.EnabledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.enable.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py new file mode 100644 index 00000000000..031034a32df --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantOperations: + """TenantOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TenantListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', 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': '/tenants'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/models/__init__.py b/src/account/azext_account/vendored_sdks/subscription/models/__init__.py index f2697f683e3..aa5146a991e 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/__init__.py @@ -1,59 +1,87 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AdPrincipal from ._models_py3 import CanceledSubscriptionId from ._models_py3 import EnabledSubscriptionId - from ._models_py3 import ErrorResponse, ErrorResponseException - from ._models_py3 import ModernCspSubscriptionCreationParameters - from ._models_py3 import ModernSubscriptionCreationParameters + from ._models_py3 import ErrorResponse + from ._models_py3 import ErrorResponseBody + from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult + from ._models_py3 import PutAliasListResult + from ._models_py3 import PutAliasRequest + from ._models_py3 import PutAliasRequestProperties + from ._models_py3 import PutAliasResponse + from ._models_py3 import PutAliasResponseProperties from ._models_py3 import RenamedSubscriptionId - from ._models_py3 import SubscriptionCreationParameters - from ._models_py3 import SubscriptionCreationResult + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionName + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult except (SyntaxError, ImportError): - from ._models import AdPrincipal - from ._models import CanceledSubscriptionId - from ._models import EnabledSubscriptionId - from ._models import ErrorResponse, ErrorResponseException - from ._models import ModernCspSubscriptionCreationParameters - from ._models import ModernSubscriptionCreationParameters - from ._models import Operation - from ._models import OperationDisplay - from ._models import OperationListResult - from ._models import RenamedSubscriptionId - from ._models import SubscriptionCreationParameters - from ._models import SubscriptionCreationResult - from ._models import SubscriptionName + from ._models import CanceledSubscriptionId # type: ignore + from ._models import EnabledSubscriptionId # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ErrorResponseBody # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import PutAliasListResult # type: ignore + from ._models import PutAliasRequest # type: ignore + from ._models import PutAliasRequestProperties # type: ignore + from ._models import PutAliasResponse # type: ignore + from ._models import PutAliasResponseProperties # type: ignore + from ._models import RenamedSubscriptionId # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionName # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + from ._subscription_client_enums import ( - OfferType, + ProvisioningState, + SpendingLimit, + SubscriptionState, + Workload, ) __all__ = [ - 'AdPrincipal', 'CanceledSubscriptionId', 'EnabledSubscriptionId', - 'ErrorResponse', 'ErrorResponseException', - 'ModernCspSubscriptionCreationParameters', - 'ModernSubscriptionCreationParameters', + 'ErrorResponse', + 'ErrorResponseBody', + 'Location', + 'LocationListResult', 'Operation', 'OperationDisplay', 'OperationListResult', + 'PutAliasListResult', + 'PutAliasRequest', + 'PutAliasRequestProperties', + 'PutAliasResponse', + 'PutAliasResponseProperties', 'RenamedSubscriptionId', - 'SubscriptionCreationParameters', - 'SubscriptionCreationResult', + 'Subscription', + 'SubscriptionListResult', 'SubscriptionName', - 'OfferType', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'ProvisioningState', + 'SpendingLimit', + 'SubscriptionState', + 'Workload', ] 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 f2d78844b32..006dd95abc5 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -1,47 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AdPrincipal(Model): - """Active Directory Principal who’ll get owner access on the new subscription. - - All required parameters must be populated in order to send to Azure. - - :param object_id: Required. Object id of the Principal - :type object_id: str - """ - - _validation = { - 'object_id': {'required': True}, - } - - _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(AdPrincipal, self).__init__(**kwargs) - self.object_id = kwargs.get('object_id', None) - - -class CanceledSubscriptionId(Model): +class CanceledSubscriptionId(msrest.serialization.Model): """The ID of the canceled subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the canceled subscription + :ivar value: The ID of the canceled subscription. :vartype value: str """ @@ -53,26 +27,20 @@ class CanceledSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CanceledSubscriptionId, self).__init__(**kwargs) self.value = None -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class EnabledSubscriptionId(Model): +class EnabledSubscriptionId(msrest.serialization.Model): """The ID of the subscriptions that is being enabled. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being enabled + :ivar value: The ID of the subscriptions that is being enabled. :vartype value: str """ @@ -84,15 +52,18 @@ class EnabledSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(EnabledSubscriptionId, self).__init__(**kwargs) self.value = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code + :param code: Error code. :type code: str :param message: Error message indicating why the operation failed. :type message: str @@ -103,111 +74,111 @@ class ErrorResponse(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. +class ErrorResponseBody(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :param error: The details of the error. + :type error: ~subscription_client.models.ErrorResponse """ - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class ModernCspSubscriptionCreationParameters(Model): - """The parameters required to create a new CSP subscription. - - All required parameters must be populated in order to send to Azure. + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } - :param display_name: Required. The friendly name of the subscription. - :type display_name: str - :param sku_id: Required. 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. - :type sku_id: str - :param reseller_id: Reseller ID, basically MPN Id. - :type reseller_id: str + def __init__( + self, + **kwargs + ): + super(ErrorResponseBody, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class Location(msrest.serialization.Model): + """Location information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar name: The location name. + :vartype name: str + :ivar display_name: The display name of the location. + :vartype display_name: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar longitude: The longitude of the location. + :vartype longitude: str """ _validation = { - 'display_name': {'required': True}, - 'sku_id': {'required': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + 'latitude': {'readonly': True}, + 'longitude': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, - 'sku_id': {'key': 'skuId', 'type': 'str'}, - 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs): - super(ModernCspSubscriptionCreationParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.sku_id = kwargs.get('sku_id', None) - self.reseller_id = kwargs.get('reseller_id', None) - + def __init__( + self, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.display_name = None + self.latitude = None + self.longitude = None -class ModernSubscriptionCreationParameters(Model): - """The parameters required to create a new subscription. - All required parameters must be populated in order to send to Azure. +class LocationListResult(msrest.serialization.Model): + """Location list operation response. - :param display_name: Required. The friendly name of the subscription. - :type display_name: str - :param sku_id: Required. 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. - :type sku_id: str - :param cost_center: If set, the cost center will show up on the Azure - usage and charges file. - :type cost_center: str - :param owner: If specified, the AD principal will get owner access to the - subscription, along with the user who is performing the create - subscription operation - :type owner: ~azure.mgmt.subscription.models.AdPrincipal - :param management_group_id: The identifier of the management group to - which this subscription will be associated. - :type management_group_id: str + :param value: An array of locations. + :type value: list[~subscription_client.models.Location] """ - _validation = { - 'display_name': {'required': True}, - 'sku_id': {'required': True}, - } - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'sku_id': {'key': 'skuId', 'type': 'str'}, - 'cost_center': {'key': 'costCenter', 'type': 'str'}, - 'owner': {'key': 'owner', 'type': 'AdPrincipal'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Location]'}, } - def __init__(self, **kwargs): - super(ModernSubscriptionCreationParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.sku_id = kwargs.get('sku_id', None) - self.cost_center = kwargs.get('cost_center', None) - self.owner = kwargs.get('owner', None) - self.management_group_id = kwargs.get('management_group_id', None) + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation} + :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that represents the operation. - :type display: ~azure.mgmt.subscription.models.OperationDisplay + :type display: ~subscription_client.models.OperationDisplay """ _attribute_map = { @@ -215,19 +186,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Subscription + :param provider: Service provider: Microsoft.Subscription. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :param resource: Resource on which the operation is performed: Profile, endpoint, etc. :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str @@ -239,21 +212,22 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) self.operation = kwargs.get('operation', None) -class OperationListResult(Model): - """Result of the request to list operations. It contains a list of operations - and a URL link to get the next set of results. +class OperationListResult(msrest.serialization.Model): + """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~azure.mgmt.subscription.models.Operation] - :param next_link: URL to get the next set of operation list results if - there are any. + :type value: list[~subscription_client.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -262,19 +236,187 @@ class OperationListResult(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) -class RenamedSubscriptionId(Model): +class PutAliasListResult(msrest.serialization.Model): + """The list of aliases. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of alias. + :vartype value: list[~subscription_client.models.PutAliasResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PutAliasResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class PutAliasRequest(msrest.serialization.Model): + """The parameters required to create a new subscription. + + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasRequest, self).__init__(**kwargs) + self.properties = kwargs['properties'] + + +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. + :type display_name: str + :param workload: Required. The workload type of the subscription. It can be either Production + or DevTest. Possible values include: "Production", "DevTest". + :type workload: str or ~subscription_client.models.Workload + :param billing_scope: Required. Determines whether subscription is fieldLed, partnerLed or + LegacyEA. + :type billing_scope: str + :param subscription_id: This parameter can be used to create alias for existing subscription + Id. + :type subscription_id: str + """ + + _validation = { + 'display_name': {'required': True}, + 'workload': {'required': True}, + 'billing_scope': {'required': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'workload': {'key': 'workload', 'type': 'str'}, + 'billing_scope': {'key': 'billingScope', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasRequestProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.workload = kwargs['workload'] + self.billing_scope = kwargs['billing_scope'] + self.subscription_id = kwargs.get('subscription_id', None) + + +class PutAliasResponse(msrest.serialization.Model): + """Subscription Information with the alias. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the alias resource. + :vartype id: str + :ivar name: Alias ID. + :vartype name: str + :ivar type: Resource type, Microsoft.Subscription/aliases. + :vartype type: str + :param properties: Put Alias response properties. + :type properties: ~subscription_client.models.PutAliasResponseProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PutAliasResponseProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + + +class PutAliasResponseProperties(msrest.serialization.Model): + """Put subscription creation result properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :param provisioning_state: The provisioning state of the resource. Possible values include: + "Accepted", "Succeeded", "Failed". + :type provisioning_state: str or ~subscription_client.models.ProvisioningState + """ + + _validation = { + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasResponseProperties, self).__init__(**kwargs) + self.subscription_id = None + self.provisioning_state = kwargs.get('provisioning_state', None) + + +class RenamedSubscriptionId(msrest.serialization.Model): """The ID of the subscriptions that is being renamed. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being renamed + :ivar value: The ID of the subscriptions that is being renamed. :vartype value: str """ @@ -286,67 +428,99 @@ class RenamedSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RenamedSubscriptionId, self).__init__(**kwargs) self.value = None -class SubscriptionCreationParameters(Model): - """Subscription Creation Parameters required to create a new Azure - subscription. - - :param display_name: The display name of the subscription. - :type display_name: str - :param management_group_id: The Management Group Id. - :type management_group_id: str - :param owners: The list of principals that should be granted Owner access - on the subscription. Principals should be of type User, Service Principal - or Security Group. - :type owners: list[~azure.mgmt.subscription.models.AdPrincipal] - :param offer_type: 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. Possible values include: 'MS-AZR-0017P', - 'MS-AZR-0148P' - :type offer_type: str or ~azure.mgmt.subscription.models.OfferType +class Subscription(msrest.serialization.Model): + """Subscription information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the subscription. For example, + /subscriptions/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar display_name: The subscription display name. + :vartype display_name: str + :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, + and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + :vartype state: str or ~subscription_client.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: ~subscription_client.models.SubscriptionPolicies + :param authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :type authorization_source: str """ + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'state': {'readonly': True}, + } + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, - 'owners': {'key': 'owners', 'type': '[AdPrincipal]'}, - 'offer_type': {'key': 'offerType', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, } - def __init__(self, **kwargs): - super(SubscriptionCreationParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.management_group_id = kwargs.get('management_group_id', None) - self.owners = kwargs.get('owners', None) - self.offer_type = kwargs.get('offer_type', None) + def __init__( + self, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.state = None + self.subscription_policies = kwargs.get('subscription_policies', None) + self.authorization_source = kwargs.get('authorization_source', None) -class SubscriptionCreationResult(Model): - """The created subscription object. +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. - :param subscription_link: The link to the new subscription. Use this link - to check the status of subscription creation operation. - :type subscription_link: str + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~subscription_client.models.Subscription] + :param next_link: Required. The URL to get the next set of results. + :type next_link: str """ + _validation = { + 'next_link': {'required': True}, + } + _attribute_map = { - 'subscription_link': {'key': 'subscriptionLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(SubscriptionCreationResult, self).__init__(**kwargs) - self.subscription_link = kwargs.get('subscription_link', None) + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] -class SubscriptionName(Model): +class SubscriptionName(msrest.serialization.Model): """The new name of the subscription. - :param subscription_name: New subscription name + :param subscription_name: New subscription name. :type subscription_name: str """ @@ -354,6 +528,107 @@ class SubscriptionName(Model): 'subscription_name': {'key': 'subscriptionName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionName, self).__init__(**kwargs) self.subscription_name = kwargs.get('subscription_name', None) + + +class SubscriptionPolicies(msrest.serialization.Model): + """Subscription policies. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. + :vartype location_placement_id: str + :ivar quota_id: The subscription quota ID. + :vartype quota_id: str + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". + :vartype spending_limit: str or ~subscription_client.models.SpendingLimit + """ + + _validation = { + 'location_placement_id': {'readonly': True}, + 'quota_id': {'readonly': True}, + 'spending_limit': {'readonly': True}, + } + + _attribute_map = { + 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, + 'quota_id': {'key': 'quotaId', 'type': 'str'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionPolicies, self).__init__(**kwargs) + self.location_placement_id = None + self.quota_id = None + self.spending_limit = None + + +class TenantIdDescription(msrest.serialization.Model): + """Tenant Id information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the tenant. For example, + /tenants/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + :vartype tenant_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of tenants. + :type value: list[~subscription_client.models.TenantIdDescription] + :param next_link: Required. The URL to use for getting the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] 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 426f15a0863..9e8a6ed53e4 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 @@ -1,47 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AdPrincipal(Model): - """Active Directory Principal who’ll get owner access on the new subscription. - - All required parameters must be populated in order to send to Azure. - - :param object_id: Required. Object id of the Principal - :type object_id: str - """ - - _validation = { - 'object_id': {'required': True}, - } - - _attribute_map = { - 'object_id': {'key': 'objectId', 'type': 'str'}, - } - - def __init__(self, *, object_id: str, **kwargs) -> None: - super(AdPrincipal, self).__init__(**kwargs) - self.object_id = object_id +from ._subscription_client_enums import * -class CanceledSubscriptionId(Model): +class CanceledSubscriptionId(msrest.serialization.Model): """The ID of the canceled subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the canceled subscription + :ivar value: The ID of the canceled subscription. :vartype value: str """ @@ -53,26 +31,20 @@ class CanceledSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(CanceledSubscriptionId, self).__init__(**kwargs) self.value = None -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class EnabledSubscriptionId(Model): +class EnabledSubscriptionId(msrest.serialization.Model): """The ID of the subscriptions that is being enabled. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being enabled + :ivar value: The ID of the subscriptions that is being enabled. :vartype value: str """ @@ -84,15 +56,18 @@ class EnabledSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(EnabledSubscriptionId, self).__init__(**kwargs) self.value = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code + :param code: Error code. :type code: str :param message: Error message indicating why the operation failed. :type message: str @@ -103,111 +78,118 @@ class ErrorResponse(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. +class ErrorResponseBody(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :param error: The details of the error. + :type error: ~subscription_client.models.ErrorResponse """ - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class ModernCspSubscriptionCreationParameters(Model): - """The parameters required to create a new CSP subscription. - - All required parameters must be populated in order to send to Azure. + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } - :param display_name: Required. The friendly name of the subscription. - :type display_name: str - :param sku_id: Required. 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. - :type sku_id: str - :param reseller_id: Reseller ID, basically MPN Id. - :type reseller_id: str + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + super(ErrorResponseBody, self).__init__(**kwargs) + self.error = error + + +class Location(msrest.serialization.Model): + """Location information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the location. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar name: The location name. + :vartype name: str + :ivar display_name: The display name of the location. + :vartype display_name: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar longitude: The longitude of the location. + :vartype longitude: str """ _validation = { - 'display_name': {'required': True}, - 'sku_id': {'required': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + 'latitude': {'readonly': True}, + 'longitude': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, - 'sku_id': {'key': 'skuId', 'type': 'str'}, - 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, *, display_name: str, sku_id: str, reseller_id: str=None, **kwargs) -> None: - super(ModernCspSubscriptionCreationParameters, self).__init__(**kwargs) - self.display_name = display_name - self.sku_id = sku_id - self.reseller_id = reseller_id + def __init__( + self, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.display_name = None + self.latitude = None + self.longitude = None -class ModernSubscriptionCreationParameters(Model): - """The parameters required to create a new subscription. - - All required parameters must be populated in order to send to Azure. +class LocationListResult(msrest.serialization.Model): + """Location list operation response. - :param display_name: Required. The friendly name of the subscription. - :type display_name: str - :param sku_id: Required. 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. - :type sku_id: str - :param cost_center: If set, the cost center will show up on the Azure - usage and charges file. - :type cost_center: str - :param owner: If specified, the AD principal will get owner access to the - subscription, along with the user who is performing the create - subscription operation - :type owner: ~azure.mgmt.subscription.models.AdPrincipal - :param management_group_id: The identifier of the management group to - which this subscription will be associated. - :type management_group_id: str + :param value: An array of locations. + :type value: list[~subscription_client.models.Location] """ - _validation = { - 'display_name': {'required': True}, - 'sku_id': {'required': True}, - } - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'sku_id': {'key': 'skuId', 'type': 'str'}, - 'cost_center': {'key': 'costCenter', 'type': 'str'}, - 'owner': {'key': 'owner', 'type': 'AdPrincipal'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Location]'}, } - def __init__(self, *, display_name: str, sku_id: str, cost_center: str=None, owner=None, management_group_id: str=None, **kwargs) -> None: - super(ModernSubscriptionCreationParameters, self).__init__(**kwargs) - self.display_name = display_name - self.sku_id = sku_id - self.cost_center = cost_center - self.owner = owner - self.management_group_id = management_group_id + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value -class Operation(Model): +class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation} + :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that represents the operation. - :type display: ~azure.mgmt.subscription.models.OperationDisplay + :type display: ~subscription_client.models.OperationDisplay """ _attribute_map = { @@ -215,19 +197,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Subscription + :param provider: Service provider: Microsoft.Subscription. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :param resource: Resource on which the operation is performed: Profile, endpoint, etc. :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str @@ -239,21 +226,26 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(Model): - """Result of the request to list operations. It contains a list of operations - and a URL link to get the next set of results. +class OperationListResult(msrest.serialization.Model): + """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~azure.mgmt.subscription.models.Operation] - :param next_link: URL to get the next set of operation list results if - there are any. + :type value: list[~subscription_client.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -262,91 +254,311 @@ class OperationListResult(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link -class RenamedSubscriptionId(Model): - """The ID of the subscriptions that is being renamed. +class PutAliasListResult(msrest.serialization.Model): + """The list of aliases. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being renamed - :vartype value: str + :ivar value: The list of alias. + :vartype value: list[~subscription_client.models.PutAliasResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str """ _validation = { 'value': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[PutAliasResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: - super(RenamedSubscriptionId, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(PutAliasListResult, self).__init__(**kwargs) self.value = None + self.next_link = None -class SubscriptionCreationParameters(Model): - """Subscription Creation Parameters required to create a new Azure - subscription. +class PutAliasRequest(msrest.serialization.Model): + """The parameters required to create a new subscription. - :param display_name: The display name of the subscription. + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + """ + + _validation = { + 'properties': {'required': True}, + } + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + } + + def __init__( + self, + *, + properties: "PutAliasRequestProperties", + **kwargs + ): + super(PutAliasRequest, self).__init__(**kwargs) + self.properties = properties + + +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. :type display_name: str - :param management_group_id: The Management Group Id. - :type management_group_id: str - :param owners: The list of principals that should be granted Owner access - on the subscription. Principals should be of type User, Service Principal - or Security Group. - :type owners: list[~azure.mgmt.subscription.models.AdPrincipal] - :param offer_type: 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. Possible values include: 'MS-AZR-0017P', - 'MS-AZR-0148P' - :type offer_type: str or ~azure.mgmt.subscription.models.OfferType + :param workload: Required. The workload type of the subscription. It can be either Production + or DevTest. Possible values include: "Production", "DevTest". + :type workload: str or ~subscription_client.models.Workload + :param billing_scope: Required. Determines whether subscription is fieldLed, partnerLed or + LegacyEA. + :type billing_scope: str + :param subscription_id: This parameter can be used to create alias for existing subscription + Id. + :type subscription_id: str """ + _validation = { + 'display_name': {'required': True}, + 'workload': {'required': True}, + 'billing_scope': {'required': True}, + } + _attribute_map = { 'display_name': {'key': 'displayName', 'type': 'str'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, - 'owners': {'key': 'owners', 'type': '[AdPrincipal]'}, - 'offer_type': {'key': 'offerType', 'type': 'str'}, + 'workload': {'key': 'workload', 'type': 'str'}, + 'billing_scope': {'key': 'billingScope', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, management_group_id: str=None, owners=None, offer_type=None, **kwargs) -> None: - super(SubscriptionCreationParameters, self).__init__(**kwargs) + def __init__( + self, + *, + display_name: str, + workload: Union[str, "Workload"], + billing_scope: str, + subscription_id: Optional[str] = None, + **kwargs + ): + super(PutAliasRequestProperties, self).__init__(**kwargs) self.display_name = display_name - self.management_group_id = management_group_id - self.owners = owners - self.offer_type = offer_type + self.workload = workload + self.billing_scope = billing_scope + self.subscription_id = subscription_id + +class PutAliasResponse(msrest.serialization.Model): + """Subscription Information with the alias. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the alias resource. + :vartype id: str + :ivar name: Alias ID. + :vartype name: str + :ivar type: Resource type, Microsoft.Subscription/aliases. + :vartype type: str + :param properties: Put Alias response properties. + :type properties: ~subscription_client.models.PutAliasResponseProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } -class SubscriptionCreationResult(Model): - """The created subscription object. + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PutAliasResponseProperties'}, + } - :param subscription_link: The link to the new subscription. Use this link - to check the status of subscription creation operation. - :type subscription_link: str + def __init__( + self, + *, + properties: Optional["PutAliasResponseProperties"] = None, + **kwargs + ): + super(PutAliasResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class PutAliasResponseProperties(msrest.serialization.Model): + """Put subscription creation result properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :param provisioning_state: The provisioning state of the resource. Possible values include: + "Accepted", "Succeeded", "Failed". + :type provisioning_state: str or ~subscription_client.models.ProvisioningState """ + _validation = { + 'subscription_id': {'readonly': True}, + } + _attribute_map = { - 'subscription_link': {'key': 'subscriptionLink', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, subscription_link: str=None, **kwargs) -> None: - super(SubscriptionCreationResult, self).__init__(**kwargs) - self.subscription_link = subscription_link + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + **kwargs + ): + super(PutAliasResponseProperties, self).__init__(**kwargs) + self.subscription_id = None + self.provisioning_state = provisioning_state + + +class RenamedSubscriptionId(msrest.serialization.Model): + """The ID of the subscriptions that is being renamed. + Variables are only populated by the server, and will be ignored when sending a request. -class SubscriptionName(Model): + :ivar value: The ID of the subscriptions that is being renamed. + :vartype value: str + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RenamedSubscriptionId, self).__init__(**kwargs) + self.value = None + + +class Subscription(msrest.serialization.Model): + """Subscription information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID for the subscription. For example, + /subscriptions/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar subscription_id: The subscription ID. + :vartype subscription_id: str + :ivar display_name: The subscription display name. + :vartype display_name: str + :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, + and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + :vartype state: str or ~subscription_client.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: ~subscription_client.models.SubscriptionPolicies + :param authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :type authorization_source: str + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + } + + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + + +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~subscription_client.models.Subscription] + :param next_link: Required. The URL to get the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionName(msrest.serialization.Model): """The new name of the subscription. - :param subscription_name: New subscription name + :param subscription_name: New subscription name. :type subscription_name: str """ @@ -354,6 +566,112 @@ class SubscriptionName(Model): 'subscription_name': {'key': 'subscriptionName', 'type': 'str'}, } - def __init__(self, *, subscription_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_name: Optional[str] = None, + **kwargs + ): super(SubscriptionName, self).__init__(**kwargs) self.subscription_name = subscription_name + + +class SubscriptionPolicies(msrest.serialization.Model): + """Subscription policies. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. + :vartype location_placement_id: str + :ivar quota_id: The subscription quota ID. + :vartype quota_id: str + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". + :vartype spending_limit: str or ~subscription_client.models.SpendingLimit + """ + + _validation = { + 'location_placement_id': {'readonly': True}, + 'quota_id': {'readonly': True}, + 'spending_limit': {'readonly': True}, + } + + _attribute_map = { + 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, + 'quota_id': {'key': 'quotaId', 'type': 'str'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionPolicies, self).__init__(**kwargs) + self.location_placement_id = None + self.quota_id = None + self.spending_limit = None + + +class TenantIdDescription(msrest.serialization.Model): + """Tenant Id information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The fully qualified ID of the tenant. For example, + /tenants/00000000-0000-0000-0000-000000000000. + :vartype id: str + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + :vartype tenant_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of tenants. + :type value: list[~subscription_client.models.TenantIdDescription] + :param next_link: Required. The URL to use for getting the next set of results. + :type next_link: str + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + super(TenantListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py b/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py index e3cb19de0f9..206c7ec8e42 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py @@ -1,18 +1,42 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class ProvisioningState(str, Enum): + """The provisioning state of the resource. + """ -class OfferType(str, Enum): + accepted = "Accepted" + succeeded = "Succeeded" + failed = "Failed" - ms_azr_0017_p = "MS-AZR-0017P" - ms_azr_0148_p = "MS-AZR-0148P" +class SpendingLimit(str, Enum): + """The subscription spending limit. + """ + + on = "On" + off = "Off" + current_period_off = "CurrentPeriodOff" + +class SubscriptionState(str, Enum): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + enabled = "Enabled" + warned = "Warned" + past_due = "PastDue" + disabled = "Disabled" + deleted = "Deleted" + +class Workload(str, Enum): + """The workload type of the subscription. It can be either Production or DevTest. + """ + + production = "Production" + dev_test = "DevTest" 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 c3d7eb6308b..7b42bb434c7 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py @@ -1,20 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._subscription_operations import SubscriptionOperations -from ._subscription_operation_operations import SubscriptionOperationOperations -from ._operations import Operations +from ._tenant_operations import TenantOperations +from ._operation_operations import OperationOperations +from ._alias_operations import AliasOperations __all__ = [ 'SubscriptionOperations', - 'SubscriptionOperationOperations', - 'Operations', + 'TenantOperations', + 'OperationOperations', + 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py new file mode 100644 index 00000000000..e15d82be8c8 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py @@ -0,0 +1,304 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AliasOperations(object): + """AliasOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_initial( + self, + alias_name, # type: str + properties, # type: "models.PutAliasRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasResponse" + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.PutAliasRequest(properties=properties) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def begin_create( + self, + alias_name, # type: str + properties, # type: "models.PutAliasRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Create Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either PutAliasResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.PutAliasResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def get( + self, + alias_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasResponse" + """Get Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def delete( + self, + alias_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete Alias. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasListResult" + """Get Alias Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasListResult, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py new file mode 100644 index 00000000000..802af6c405a --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.OperationListResult" + """Lists all of the available Microsoft.Subscription API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult, or the result of cls(response) + :rtype: ~subscription_client.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py index cfede3b61f1..cda5e0b6ad2 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 @@ -1,557 +1,397 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionOperations(object): """SubscriptionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :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_location( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - self.config = config + Gets all available geo-locations. + :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): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + 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" - def _create_subscription_in_enrollment_account_initial( - self, enrollment_account_name, body, custom_headers=None, raw=False, **operation_config): # Construct URL - url = self.create_subscription_in_enrollment_account.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'enrollmentAccountName': self._serialize.url("enrollment_account_name", enrollment_account_name, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - 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 body - body_content = self._serialize.body(body, 'SubscriptionCreationParameters') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - deserialized = None - header_dict = {} + 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) - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('Subscription', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_subscription_in_enrollment_account( - self, enrollment_account_name, body, custom_headers=None, raw=False, polling=True, **operation_config): - """Creates an Azure subscription. - - :param enrollment_account_name: The name of the enrollment account to - which the subscription will be billed. - :type enrollment_account_name: str - :param body: The subscription creation parameters. - :type body: - ~azure.mgmt.subscription.models.SubscriptionCreationParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns - SubscriptionCreationResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] - :raises: - :class:`ErrorResponseException` + 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 """ - raw_result = self._create_subscription_in_enrollment_account_initial( - enrollment_account_name=enrollment_account_name, - body=body, - custom_headers=custom_headers, - raw=True, - **operation_config + 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): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + 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 ) - - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_subscription_in_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} + list.metadata = {'url': '/subscriptions'} # type: ignore def cancel( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CanceledSubscriptionId" """The operation to cancel a subscription. :param subscription_id: Subscription Id. :type subscription_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: CanceledSubscriptionId or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CanceledSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.CanceledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + # Construct URL - url = self.cancel.metadata['url'] + url = self.cancel.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] 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.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CanceledSubscriptionId', response) + deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore def rename( - self, subscription_id, subscription_name=None, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + subscription_name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.RenamedSubscriptionId" """The operation to rename a subscription. :param subscription_id: Subscription Id. :type subscription_id: str - :param subscription_name: New subscription name + :param subscription_name: New subscription name. :type subscription_name: 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: RenamedSubscriptionId or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RenamedSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.RenamedSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError """ - body = models.SubscriptionName(subscription_name=subscription_name) + cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.SubscriptionName(subscription_name=subscription_name) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.rename.metadata['url'] + url = self.rename.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - 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 body - body_content = self._serialize.body(body, 'SubscriptionName') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'SubscriptionName') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RenamedSubscriptionId', response) + deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} + rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore def enable( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.EnabledSubscriptionId" """The operation to enable a subscription. :param subscription_id: Subscription Id. :type subscription_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: EnabledSubscriptionId or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnabledSubscriptionId, or the result of cls(response) + :rtype: ~subscription_client.models.EnabledSubscriptionId + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + # Construct URL - url = self.enable.metadata['url'] + url = self.enable.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] 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.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('EnabledSubscriptionId', response) + deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} - - - def _create_subscription_initial( - self, billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers=None, raw=False, **operation_config): - # Construct URL - url = self.create_subscription.metadata['url'] - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, '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' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - 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 body - body_content = self._serialize.body(body, 'ModernSubscriptionCreationParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - header_dict = {} - - 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 - - def create_subscription( - self, billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers=None, raw=False, polling=True, **operation_config): - """The operation to create a new WebDirect or EA Azure subscription. - - :param billing_account_name: The name of the Microsoft Customer - Agreement billing account for which you want to create the - subscription. - :type billing_account_name: str - :param billing_profile_name: The name of the billing profile in the - billing account for which you want to create the subscription. - :type billing_profile_name: str - :param invoice_section_name: The name of the invoice section in the - billing account for which you want to create the subscription. - :type invoice_section_name: str - :param body: The subscription creation parameters. - :type body: - ~azure.mgmt.subscription.models.ModernSubscriptionCreationParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns - SubscriptionCreationResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] - :raises: - :class:`ErrorResponseException` - """ - raw_result = self._create_subscription_initial( - billing_account_name=billing_account_name, - billing_profile_name=billing_profile_name, - invoice_section_name=invoice_section_name, - body=body, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} - - - def _create_csp_subscription_initial( - self, billing_account_name, customer_name, body, custom_headers=None, raw=False, **operation_config): - # Construct URL - url = self.create_csp_subscription.metadata['url'] - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, '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' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - 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 body - body_content = self._serialize.body(body, 'ModernCspSubscriptionCreationParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - header_dict = {} - - 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 - - def create_csp_subscription( - self, billing_account_name, customer_name, body, custom_headers=None, raw=False, polling=True, **operation_config): - """The operation to create a new CSP subscription. - - :param billing_account_name: The name of the Microsoft Customer - Agreement billing account for which you want to create the - subscription. - :type billing_account_name: str - :param customer_name: The name of the customer. - :type customer_name: str - :param body: The subscription creation parameters. - :type body: - ~azure.mgmt.subscription.models.ModernCspSubscriptionCreationParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :return: An instance of LROPoller that returns - SubscriptionCreationResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.SubscriptionCreationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.SubscriptionCreationResult]] - :raises: - :class:`ErrorResponseException` - """ - raw_result = self._create_csp_subscription_initial( - billing_account_name=billing_account_name, - customer_name=customer_name, - body=body, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - - return deserialized - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_csp_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} + enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py new file mode 100644 index 00000000000..191387ae6fe --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantOperations(object): + """TenantOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TenantListResult"] + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TenantListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', 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': '/tenants'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/py.typed b/src/account/azext_account/vendored_sdks/subscription/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file From a1f06267a233f045e6970a5f8c1ebc6ffb397872 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Thu, 3 Sep 2020 17:47:29 +0800 Subject: [PATCH 03/12] latest codegen SDK --- .../vendored_sdks/subscription/__init__.py | 2 +- .../subscription/_configuration.py | 2 + .../subscription/aio/_configuration_async.py | 2 + .../_alias_operations_async.py | 42 ++++++++------ .../_operation_operations_async.py | 1 - .../_subscription_operations_async.py | 33 +++++------ .../_tenant_operations_async.py | 12 ++-- .../models/_subscription_client_enums.py | 56 ++++++++++++------- .../operations/_alias_operations.py | 32 ++++++----- .../operations/_operation_operations.py | 1 - .../operations/_subscription_operations.py | 33 +++++------ .../operations/_tenant_operations.py | 12 ++-- 12 files changed, 127 insertions(+), 101 deletions(-) diff --git a/src/account/azext_account/vendored_sdks/subscription/__init__.py b/src/account/azext_account/vendored_sdks/subscription/__init__.py index b07b0882922..a1d3eed7425 100644 --- a/src/account/azext_account/vendored_sdks/subscription/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/__init__.py @@ -10,7 +10,7 @@ __all__ = ['SubscriptionClient'] try: - from ._patch import patch_sdk + from ._patch import patch_sdk # type: ignore patch_sdk() except ImportError: pass diff --git a/src/account/azext_account/vendored_sdks/subscription/_configuration.py b/src/account/azext_account/vendored_sdks/subscription/_configuration.py index e3e69420927..b7302055ff8 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_configuration.py +++ b/src/account/azext_account/vendored_sdks/subscription/_configuration.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -54,6 +55,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py index d671822a671..799e460b7d1 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_configuration_async.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -50,6 +51,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py index d5e817b84b3..5b6584fd311 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py @@ -11,7 +11,7 @@ from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -72,7 +72,6 @@ async def _create_initial( header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'PutAliasRequest') body_content_kwargs['content'] = body_content @@ -86,7 +85,6 @@ async def _create_initial( error = self._deserialize(models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('PutAliasResponse', pipeline_response) @@ -99,12 +97,12 @@ async def _create_initial( return deserialized _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore - async def create( + async def begin_create( self, alias_name: str, properties: "models.PutAliasRequestProperties", **kwargs - ) -> "models.PutAliasResponse": + ) -> AsyncLROPoller["models.PutAliasResponse"]: """Create Alias Subscription. :param alias_name: Alias Name. @@ -112,12 +110,13 @@ async def create( :param properties: Put alias request properties. :type properties: ~subscription_client.models.PutAliasRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: PutAliasResponse, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasResponse + :return: An instance of AsyncLROPoller that returns either PutAliasResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~subscription_client.models.PutAliasResponse] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] @@ -126,12 +125,14 @@ async def create( 'polling_interval', self._config.polling_interval ) - raw_result = await self._create_initial( - alias_name=alias_name, - properties=properties, - cls=lambda x,y,z: x, - **kwargs - ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) @@ -146,8 +147,16 @@ def get_long_running_output(pipeline_response): if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling - return await async_poller(self._client, raw_result, get_long_running_output, polling_method) - create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore async def get( self, @@ -183,7 +192,6 @@ async def get( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,7 +242,6 @@ async def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,7 +283,6 @@ async def list( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py index dc4efebc375..25c797735e9 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_operation_operations_async.py @@ -67,7 +67,6 @@ async def list( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response 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 97d2463fd20..287209147a0 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 @@ -46,9 +46,10 @@ def list_location( subscription_id: str, **kwargs ) -> AsyncIterable["models.LocationListResult"]: - """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + """Gets all available geo-locations. - 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 @@ -63,6 +64,10 @@ def list_location( 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 @@ -74,15 +79,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -143,7 +144,6 @@ async def get( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,6 +177,10 @@ def list( 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 @@ -184,15 +188,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -253,7 +253,6 @@ async def cancel( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -312,7 +311,6 @@ async def rename( header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'SubscriptionName') body_content_kwargs['content'] = body_content @@ -368,7 +366,6 @@ async def enable( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py index 031034a32df..06120525696 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_tenant_operations_async.py @@ -58,6 +58,10 @@ def list( 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 @@ -65,15 +69,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py b/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py index 206c7ec8e42..18d7d3d3fcc 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_subscription_client_enums.py @@ -6,37 +6,55 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum - -class ProvisioningState(str, Enum): +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the resource. """ - accepted = "Accepted" - succeeded = "Succeeded" - failed = "Failed" + ACCEPTED = "Accepted" + SUCCEEDED = "Succeeded" + FAILED = "Failed" -class SpendingLimit(str, Enum): +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ - on = "On" - off = "Off" - current_period_off = "CurrentPeriodOff" + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(str, Enum): +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ - enabled = "Enabled" - warned = "Warned" - past_due = "PastDue" - disabled = "Disabled" - deleted = "Deleted" + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" -class Workload(str, Enum): +class Workload(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The workload type of the subscription. It can be either Production or DevTest. """ - production = "Production" - dev_test = "DevTest" + PRODUCTION = "Production" + DEV_TEST = "DevTest" diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py index e15d82be8c8..6fcfec9abc2 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py @@ -77,7 +77,6 @@ def _create_initial( header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'PutAliasRequest') body_content_kwargs['content'] = body_content @@ -91,7 +90,6 @@ def _create_initial( error = self._deserialize(models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('PutAliasResponse', pipeline_response) @@ -110,7 +108,7 @@ def begin_create( properties, # type: "models.PutAliasRequestProperties" **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.PutAliasResponse"] """Create Alias Subscription. :param alias_name: Alias Name. @@ -118,6 +116,7 @@ def begin_create( :param properties: Put alias request properties. :type properties: ~subscription_client.models.PutAliasRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy :paramtype polling: bool or ~azure.core.polling.PollingMethod @@ -132,12 +131,14 @@ def begin_create( 'polling_interval', self._config.polling_interval ) - raw_result = self._create_initial( - alias_name=alias_name, - properties=properties, - cls=lambda x,y,z: x, - **kwargs - ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) @@ -152,7 +153,15 @@ def get_long_running_output(pipeline_response): if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore def get( @@ -190,7 +199,6 @@ def get( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,7 +250,6 @@ def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,7 +292,6 @@ def list( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py index 802af6c405a..ad81bbff54c 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_operation_operations.py @@ -72,7 +72,6 @@ def list( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response 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 cda5e0b6ad2..9e068481e4c 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 @@ -51,9 +51,10 @@ def list_location( **kwargs # type: Any ): # type: (...) -> Iterable["models.LocationListResult"] - """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + """Gets all available geo-locations. - 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 @@ -68,6 +69,10 @@ def list_location( 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 @@ -79,15 +84,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -149,7 +150,6 @@ def get( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -184,6 +184,10 @@ def list( 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 @@ -191,15 +195,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -261,7 +261,6 @@ def cancel( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -321,7 +320,6 @@ def rename( header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - # Construct and send request body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(_body, 'SubscriptionName') body_content_kwargs['content'] = body_content @@ -378,7 +376,6 @@ def enable( header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py index 191387ae6fe..57584209e20 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_tenant_operations.py @@ -63,6 +63,10 @@ def list( 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 @@ -70,15 +74,11 @@ def prepare_request(next_link=None): 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] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): From d8ad1a21ce3a4f34617fb366440346fc67093ba6 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Fri, 4 Sep 2020 17:20:22 +0800 Subject: [PATCH 04/12] add tests --- .../generated/_client_factory.py | 2 +- src/account/azext_account/generated/_help.py | 17 +- .../azext_account/generated/_params.py | 14 +- src/account/azext_account/generated/action.py | 38 ----- src/account/azext_account/generated/custom.py | 11 +- .../tests/latest/test_account_scenario.py | 158 +++++++++--------- .../subscription/models/_models.py | 2 - .../subscription/models/_models_py3.py | 2 - 8 files changed, 101 insertions(+), 143 deletions(-) delete mode 100644 src/account/azext_account/generated/action.py diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index 5e9570852cd..89637e56536 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -9,7 +9,7 @@ def cf_account(cli_ctx, *_): from ..vendored_sdks.subscription import SubscriptionClient return _get_mgmt_service_client(cli_ctx, SubscriptionClient, subscription_bound=False, - base_url_bound=False)[0] + base_url_bound=True)[0] def cf_subscription(cli_ctx, *_): diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index ced8f63e8e1..1409fc73959 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -107,22 +107,13 @@ 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 - display-name: Required. The friendly name of the subscription. - workload: Required. The workload type of the subscription. It can be either Production or DevTest. - billing-scope: Required. Determines whether subscription is fieldLed, partnerLed or LegacyEA - subscription-id: This parameter can be used to create alias for existing subscription Id + short-summary: "Create Alias Subscription." examples: - name: CreateAlias text: |- - 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" + az account alias create --name "aliasForNewSub" --billing-scope "/providers/Microsoft.Billing/billingAcc\ +ounts/e879cf0f-2b4d-5431-109a-f72fc9868693: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" """ helps['account alias delete'] = """ diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index e46405ebdd0..ed070590459 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -6,14 +6,14 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from azext_account.action import AddProperties +from azure.cli.core.commands.parameters import get_enum_type def load_arguments(self, _): with self.argument_context('account subscription rename') as c: c.argument('subscription_id', help='Subscription Id.') - c.argument('subscription_name', help='New subscription name') + c.argument('subscription_name', options_list=['--name', '-n'], help='New subscription name') with self.argument_context('account subscription cancel') as c: c.argument('subscription_id', help='Subscription Id.') @@ -40,8 +40,14 @@ def load_arguments(self, _): c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') with self.argument_context('account alias create') as c: - c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') - c.argument('properties', action=AddProperties, nargs='+', help='Put alias request properties.') + c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], 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='Determines whether subscription is fieldLed, partnerLed or ' + 'LegacyEA') + c.argument('subscription_id', type=str, help='This parameter can be used to create alias for existing ' + 'subscription Id') with self.argument_context('account alias delete') as c: c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') diff --git a/src/account/azext_account/generated/action.py b/src/account/azext_account/generated/action.py deleted file mode 100644 index 0d4cd4ef8af..00000000000 --- a/src/account/azext_account/generated/action.py +++ /dev/null @@ -1,38 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# 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] - return d diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 0b7dd4b47ec..529ef152131 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -105,8 +105,17 @@ def account_alias_show(client, def account_alias_create(client, alias_name, - properties, + display_name=None, + workload=None, + billing_scope=None, + subscription_id=None, 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/tests/latest/test_account_scenario.py b/src/account/azext_account/tests/latest/test_account_scenario.py index 92d77b58d79..de540a50485 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -5,6 +5,7 @@ import os import unittest +import time from azure_devtools.scenario_tests import AllowLargeResponse from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) @@ -15,87 +16,80 @@ class SubscriptionClientScenarioTest(ScenarioTest): - @ResourceGroupPreparer(name_prefix='cli_test_account') - def test_account(self, resource_group): - - self.cmd('az account subscription create ' - '--billing-account-name "0aa27f2b-ec7f-5a65-71f6-a5ff0897bd55:ae0dae1e-de9a-41f6-8257-76b055d98372_2019-05-31" ' - '--billing-profile-name "27VR-HDWX-BG7-TGB" ' - '--cost-center "135366376" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--invoice-section-name "JGF7-NSBG-PJA-TGB"', - checks=[]) - - self.cmd('az account subscription create-subscription-in-enrollment-account ' - '--display-name "Test Ea Azure Sub" ' - '--offer-type "MS-AZR-0017P" ' - '--enrollment-account-name "73f8ab6e-cfa0-42be-b886-be6e77c2980c"', - checks=[]) - - self.cmd('az account subscription create-csp-subscription ' - '--billing-account-name "2bc54a6f-8d8a-5be1-5bff-bb4f285f512b:11a72812-d9a4-446e-9a1e-70c8bcadf5c0_2019-05-31" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--customer-name "e33ba30d-3718-4b15-bfaa-5627a57cda6f"', - checks=[]) - - self.cmd('az account subscription create ' - '--billing-account-name "0aa27f2b-ec7f-5a65-71f6-a5ff0897bd55:ae0dae1e-de9a-41f6-8257-76b055d98372_2019-05-31" ' - '--billing-profile-name "27VR-HDWX-BG7-TGB" ' - '--cost-center "135366376" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--invoice-section-name "JGF7-NSBG-PJA-TGB"', - checks=[]) - - self.cmd('az account subscription create-subscription-in-enrollment-account ' - '--display-name "Test Ea Azure Sub" ' - '--offer-type "MS-AZR-0017P" ' - '--enrollment-account-name "73f8ab6e-cfa0-42be-b886-be6e77c2980c"', - checks=[]) - - self.cmd('az account subscription create-csp-subscription ' - '--billing-account-name "2bc54a6f-8d8a-5be1-5bff-bb4f285f512b:11a72812-d9a4-446e-9a1e-70c8bcadf5c0_2019-05-31" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--customer-name "e33ba30d-3718-4b15-bfaa-5627a57cda6f"', - checks=[]) - - self.cmd('az account subscription create ' - '--billing-account-name "0aa27f2b-ec7f-5a65-71f6-a5ff0897bd55:ae0dae1e-de9a-41f6-8257-76b055d98372_2019-05-31" ' - '--billing-profile-name "27VR-HDWX-BG7-TGB" ' - '--cost-center "135366376" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--invoice-section-name "JGF7-NSBG-PJA-TGB"', + # @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" + }) + + 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}) + + # 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}')]) + if self.in_recording: + 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}')]) + if self.in_recording: + 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}')]) + if self.in_recording: + time.sleep(300) + 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 subscription create-subscription-in-enrollment-account ' - '--display-name "Test Ea Azure Sub" ' - '--offer-type "MS-AZR-0017P" ' - '--enrollment-account-name "73f8ab6e-cfa0-42be-b886-be6e77c2980c"', - checks=[]) - - self.cmd('az account subscription create-csp-subscription ' - '--billing-account-name "2bc54a6f-8d8a-5be1-5bff-bb4f285f512b:11a72812-d9a4-446e-9a1e-70c8bcadf5c0_2019-05-31" ' - '--display-name "Contoso MCA subscription" ' - '--sku-id "0001" ' - '--customer-name "e33ba30d-3718-4b15-bfaa-5627a57cda6f"', - checks=[]) - - self.cmd('az account subscription enable', - checks=[]) - - self.cmd('az account subscription cancel', - checks=[]) - - self.cmd('az account subscription rename', - checks=[]) - - self.cmd('az account subscription-operation show ' - '--operation-id "e4b8d068-f574-462a-a76f-6fa0afc613c9"', - checks=[]) - - self.cmd('az account operation list', + + 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')]) + + self.cmd('az account alias delete -n {new_alias_name}', checks=[]) 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 006dd95abc5..000c020db08 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -319,9 +319,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): """ _validation = { - 'display_name': {'required': True}, 'workload': {'required': True}, - 'billing_scope': {'required': True}, } _attribute_map = { 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 9e8a6ed53e4..3fb26707880 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 @@ -342,9 +342,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): """ _validation = { - 'display_name': {'required': True}, 'workload': {'required': True}, - 'billing_scope': {'required': True}, } _attribute_map = { From 5aa8ca95c33d29026a7a6b1a2dc2ee84b64e4140 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Fri, 4 Sep 2020 20:42:55 +0800 Subject: [PATCH 05/12] add recordings --- .../tests/latest/test_account_scenario.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 de540a50485..778ae4a37ff 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -36,6 +36,7 @@ def test_account(self): 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=[]) @@ -73,13 +74,13 @@ def test_account(self): self.cmd('az account subscription rename --subscription-id {subscription_id} --name "{new_display_name}"', checks=[self.check('subscriptionId', '{subscription_id}')]) - if self.in_recording: - time.sleep(300) - 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)]) + # if self.in_recording: + # 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')]) @@ -90,6 +91,7 @@ def test_account(self): 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')]) - - self.cmd('az account alias delete -n {new_alias_name}', - checks=[]) + + # no permission issue + # self.cmd('az account alias delete -n {new_alias_name}', + # checks=[]) From f5a61937c2279a00e8222131ab9c191b00b62bd8 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Fri, 4 Sep 2020 21:28:39 +0800 Subject: [PATCH 06/12] bump version --- src/account/HISTORY.rst | 6 + src/account/azext_account/action.py | 2 +- .../tests/latest/recordings/test_account.yaml | 836 ++++++++++++++++++ .../tests/latest/test_account_scenario.py | 25 +- src/account/setup.py | 2 +- 5 files changed, 855 insertions(+), 16 deletions(-) create mode 100644 src/account/azext_account/tests/latest/recordings/test_account.yaml diff --git a/src/account/HISTORY.rst b/src/account/HISTORY.rst index 1c139576ba0..b8161021ab7 100644 --- a/src/account/HISTORY.rst +++ b/src/account/HISTORY.rst @@ -3,6 +3,12 @@ Release History =============== +0.2.0 ++++++ +* Breaking Change: remove `az account subscription create` +* Add az account alias commands +* Add az account tenant commands + 0.1.0 ++++++ * Initial release. diff --git a/src/account/azext_account/action.py b/src/account/azext_account/action.py index ae52d832feb..b6a13c7554b 100644 --- a/src/account/azext_account/action.py +++ b/src/account/azext_account/action.py @@ -6,7 +6,7 @@ # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import -from azext_account.generated.action import * # noqa: F403 +# from azext_account.generated.action import * # noqa: F403 try: from azext_account.manual.action import * # noqa: F403 except ImportError: diff --git a/src/account/azext_account/tests/latest/recordings/test_account.yaml b/src/account/azext_account/tests/latest/recordings/test_account.yaml new file mode 100644 index 00000000000..a473ed8064a --- /dev/null +++ b/src/account/azext_account/tests/latest/recordings/test_account.yaml @@ -0,0 +1,836 @@ +interactions: +- request: + body: '{"properties": {"displayName": "My Subscription", "workload": "Production", + "billingScope": "/providers/Microsoft.Billing/billingAccounts/9147924/enrollmentAccounts/253727"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias create + Connection: + - keep-alive + Content-Length: + - '174' + Content-Type: + - application/json + ParameterSetName: + - --name --billing-scope --display-name --workload + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias000001?api-version=2020-09-01 + response: + body: + string: '{"id":"/providers/Microsoft.Subscription/aliases/cli_alias000001","name":"cli_alias000001","type":"Microsoft.Subscription/aliases","properties":{"subscriptionId":"00000000-0000-0000-0000-000000000000","provisioningState":"Accepted"}}' + headers: + cache-control: + - no-cache + content-length: + - '251' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:22 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - c1c02099-f330-4cd6-9ec9-8fafe691bc5f + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias create + Connection: + - keep-alive + ParameterSetName: + - --name --billing-scope --display-name --workload + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias000001?api-version=2020-09-01 + response: + body: + string: '{"id":"/providers/Microsoft.Subscription/aliases/cli_alias000001","name":"cli_alias000001","type":"Microsoft.Subscription/aliases","properties":{"subscriptionId":"00000000-0000-0000-0000-000000000000","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '252' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:52 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - 6707b895-b8b5-41c2-b50e-11bdf8dab99a + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias show + Connection: + - keep-alive + ParameterSetName: + - -n + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias000001?api-version=2020-09-01 + response: + body: + string: '{"id":"/providers/Microsoft.Subscription/aliases/cli_alias000001","name":"cli_alias000001","type":"Microsoft.Subscription/aliases","properties":{"subscriptionId":"00000000-0000-0000-0000-000000000000","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '252' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:55 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - 582ad076-64bb-4f41-ba16-fc1e91479232 + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions?api-version=2016-06-01 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"4b7571aa-8a25-4e1e-b884-e9a33cea95c5","displayName":"TestingLimit1-100","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"86bc4fb6-0fc8-4db5-8568-2f8aeb998e4c","displayName":"cli_subos5rknc3e66p3iniq","state":"Warned","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"6aaa903e-7c45-4492-8d3c-ef882bc009b5","displayName":"Feng + Alias Subscription 2","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"e35ea3b7-3091-4787-9216-d0b90889234f","displayName":"My + Subscription","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Subscription","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '1681' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:56 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription show + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000?api-version=2016-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Subscription","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}' + headers: + cache-control: + - no-cache + content-length: + - '329' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:57 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription list-location + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2016-06-01 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastasia","name":"eastasia","displayName":"East + Asia","longitude":"114.188","latitude":"22.267"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/southeastasia","name":"southeastasia","displayName":"Southeast + Asia","longitude":"103.833","latitude":"1.283"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/centralus","name":"centralus","displayName":"Central + US","longitude":"-93.6208","latitude":"41.5908"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus","name":"eastus","displayName":"East + US","longitude":"-79.8164","latitude":"37.3719"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus2","name":"eastus2","displayName":"East + US 2","longitude":"-78.3889","latitude":"36.6681"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/westus","name":"westus","displayName":"West + US","longitude":"-122.417","latitude":"37.783"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/northcentralus","name":"northcentralus","displayName":"North + Central US","longitude":"-87.6278","latitude":"41.8819"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/southcentralus","name":"southcentralus","displayName":"South + Central US","longitude":"-98.5","latitude":"29.4167"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/northeurope","name":"northeurope","displayName":"North + Europe","longitude":"-6.2597","latitude":"53.3478"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/westeurope","name":"westeurope","displayName":"West + Europe","longitude":"4.9","latitude":"52.3667"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/japanwest","name":"japanwest","displayName":"Japan + West","longitude":"135.5022","latitude":"34.6939"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/japaneast","name":"japaneast","displayName":"Japan + East","longitude":"139.77","latitude":"35.68"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/brazilsouth","name":"brazilsouth","displayName":"Brazil + South","longitude":"-46.633","latitude":"-23.55"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/australiaeast","name":"australiaeast","displayName":"Australia + East","longitude":"151.2094","latitude":"-33.86"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/australiasoutheast","name":"australiasoutheast","displayName":"Australia + Southeast","longitude":"144.9631","latitude":"-37.8136"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/southindia","name":"southindia","displayName":"South + India","longitude":"80.1636","latitude":"12.9822"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/centralindia","name":"centralindia","displayName":"Central + India","longitude":"73.9197","latitude":"18.5822"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/westindia","name":"westindia","displayName":"West + India","longitude":"72.868","latitude":"19.088"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/canadacentral","name":"canadacentral","displayName":"Canada + Central","longitude":"-79.383","latitude":"43.653"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/canadaeast","name":"canadaeast","displayName":"Canada + East","longitude":"-71.217","latitude":"46.817"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/uksouth","name":"uksouth","displayName":"UK + South","longitude":"-0.799","latitude":"50.941"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/ukwest","name":"ukwest","displayName":"UK + West","longitude":"-3.084","latitude":"53.427"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/westcentralus","name":"westcentralus","displayName":"West + Central US","longitude":"-110.234","latitude":"40.890"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/westus2","name":"westus2","displayName":"West + US 2","longitude":"-119.852","latitude":"47.233"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/koreacentral","name":"koreacentral","displayName":"Korea + Central","longitude":"126.9780","latitude":"37.5665"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/koreasouth","name":"koreasouth","displayName":"Korea + South","longitude":"129.0756","latitude":"35.1796"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/francecentral","name":"francecentral","displayName":"France + Central","longitude":"2.3730","latitude":"46.3772"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/francesouth","name":"francesouth","displayName":"France + South","longitude":"2.1972","latitude":"43.8345"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/australiacentral","name":"australiacentral","displayName":"Australia + Central","longitude":"149.1244","latitude":"-35.3075"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/australiacentral2","name":"australiacentral2","displayName":"Australia + Central 2","longitude":"149.1244","latitude":"-35.3075"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/uaecentral","name":"uaecentral","displayName":"UAE + Central","longitude":"54.366669","latitude":"24.466667"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/uaenorth","name":"uaenorth","displayName":"UAE + North","longitude":"55.316666","latitude":"25.266666"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/southafricanorth","name":"southafricanorth","displayName":"South + Africa North","longitude":"28.218370","latitude":"-25.731340"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/southafricawest","name":"southafricawest","displayName":"South + Africa West","longitude":"18.843266","latitude":"-34.075691"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/switzerlandnorth","name":"switzerlandnorth","displayName":"Switzerland + North","longitude":"8.564572","latitude":"47.451542"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/switzerlandwest","name":"switzerlandwest","displayName":"Switzerland + West","longitude":"6.143158","latitude":"46.204391"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/germanynorth","name":"germanynorth","displayName":"Germany + North","longitude":"8.806422","latitude":"53.073635"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/germanywestcentral","name":"germanywestcentral","displayName":"Germany + West Central","longitude":"8.682127","latitude":"50.110924"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/norwaywest","name":"norwaywest","displayName":"Norway + West","longitude":"5.733107","latitude":"58.969975"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/norwayeast","name":"norwayeast","displayName":"Norway + East","longitude":"10.752245","latitude":"59.913868"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/locations/brazilsoutheast","name":"brazilsoutheast","displayName":"Brazil + Southeast","longitude":"-43.2075","latitude":"-22.90278"}]}' + headers: + cache-control: + - no-cache + content-length: + - '7320' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:09:57 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription cancel + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --subscription-id --yes + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Subscription/cancel?api-version=2020-09-01 + response: + body: + string: '{"subscriptionId":"00000000-0000-0000-0000-000000000000"}' + headers: + cache-control: + - no-cache + content-length: + - '57' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:10:02 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - 74add5cb-3703-4e92-a22d-b6d7f60cba6a + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription show + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000?api-version=2016-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Subscription","state":"Warned","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}' + headers: + cache-control: + - no-cache + content-length: + - '328' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:15:02 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription enable + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Subscription/enable?api-version=2020-09-01 + response: + body: + string: '{"subscriptionId":"00000000-0000-0000-0000-000000000000"}' + headers: + cache-control: + - no-cache + content-length: + - '57' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:15:07 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - 258279d2-320a-4af0-a384-5de245323cf5 + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription show + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000?api-version=2016-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Subscription","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}' + headers: + cache-control: + - no-cache + content-length: + - '329' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:20:08 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"subscriptionName": "My Big Subscription"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription rename + Connection: + - keep-alive + Content-Length: + - '43' + Content-Type: + - application/json + ParameterSetName: + - --subscription-id --name + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Subscription/rename?api-version=2020-09-01 + response: + body: + string: '{"subscriptionId":"00000000-0000-0000-0000-000000000000"}' + headers: + cache-control: + - no-cache + content-length: + - '57' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:20:12 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - f3f68d09-b145-4b03-91ee-b1ab5a5ed5f1 + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription show + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000?api-version=2016-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Subscription","state":"Warned","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}' + headers: + cache-control: + - no-cache + content-length: + - '328' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 09:25:12 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account subscription show + Connection: + - keep-alive + ParameterSetName: + - --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000?api-version=2016-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000","authorizationSource":"Legacy","subscriptionId":"00000000-0000-0000-0000-000000000000","displayName":"My + Big Subscription","state":"Enabled","subscriptionPolicies":{"locationPlacementId":"Public_2014-09-01","quotaId":"EnterpriseAgreement_2014-09-01","spendingLimit":"Off"}}' + headers: + cache-control: + - no-cache + content-length: + - '333' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 12:20:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account tenant list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/tenants?api-version=2016-06-01 + response: + body: + string: '{"value":[{"id":"/tenants/e8abe575-baa6-4436-af8a-dbf3eeb3a857","tenantId":"e8abe575-baa6-4436-af8a-dbf3eeb3a857"}]}' + headers: + cache-control: + - no-cache + content-length: + - '116' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 12:20:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -n + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias000001?api-version=2020-09-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 04 Sep 2020 12:20:42 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - 9ee56908-7fab-4306-99cb-e2e053918afc + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +- request: + body: '{"properties": {"workload": "Production", "subscriptionId": "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias create + Connection: + - keep-alive + Content-Length: + - '100' + Content-Type: + - application/json + ParameterSetName: + - --name --workload --subscription-id + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias_new000002?api-version=2020-09-01 + response: + body: + string: '{"id":"/providers/Microsoft.Subscription/aliases/cli_alias_new000002","name":"cli_alias_new000002","type":"Microsoft.Subscription/aliases","properties":{"subscriptionId":"00000000-0000-0000-0000-000000000000","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '252' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 04 Sep 2020 12:20:45 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - d6f3d475-ee3e-4529-b28a-b985a191b268 + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 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 778ae4a37ff..bd97245328d 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -34,7 +34,7 @@ def test_account(self): checks=[self.check('name', '{alias_name}'), self.check('properties.provisioningState', 'Succeeded')]).get_output_in_json() sub_id = alias_sub['properties']['subscriptionId'] - self.kwargs.update({'subscription_id':sub_id}) + self.kwargs.update({'subscription_id': sub_id}) # response different from swagger, causing deserialization error # self.cmd('az account alias list', @@ -44,10 +44,9 @@ def test_account(self): 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)]) + 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)]) @@ -57,20 +56,18 @@ def test_account(self): if self.in_recording: 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)]) + 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}')]) if self.in_recording: 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)]) + 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}')]) @@ -87,7 +84,7 @@ def test_account(self): 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')]) diff --git a/src/account/setup.py b/src/account/setup.py index 03591dc1fe5..721b72f13be 100644 --- a/src/account/setup.py +++ b/src/account/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '0.1.0' +VERSION = '0.2.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From 4076d5df307be51e6f9a69d02dcaf3f61b69c112 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Fri, 4 Sep 2020 21:44:29 +0800 Subject: [PATCH 07/12] add validator --- src/account/azext_account/generated/_params.py | 5 +++-- src/account/azext_account/generated/_validators.py | 11 +++++++++++ src/account/azext_account/generated/custom.py | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index ed070590459..264ea7e7bd6 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -7,13 +7,14 @@ # pylint: disable=too-many-statements from azure.cli.core.commands.parameters import get_enum_type +from ._validators import alias_validator def load_arguments(self, _): with self.argument_context('account subscription rename') as c: c.argument('subscription_id', help='Subscription Id.') - c.argument('subscription_name', options_list=['--name', '-n'], help='New subscription name') + 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', help='Subscription Id.') @@ -39,7 +40,7 @@ def load_arguments(self, _): 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') as c: + with self.argument_context('account alias create', validator=alias_validator) as c: c.argument('alias_name', options_list=['--name', '-n', '--alias-name'], 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 ' diff --git a/src/account/azext_account/generated/_validators.py b/src/account/azext_account/generated/_validators.py index 34913fb394d..2d25970eeef 100644 --- a/src/account/azext_account/generated/_validators.py +++ b/src/account/azext_account/generated/_validators.py @@ -2,3 +2,14 @@ # 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: + raise CLIError('--billing-scope and --display-name are required.') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 529ef152131..3781682efae 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -105,9 +105,9 @@ def account_alias_show(client, def account_alias_create(client, alias_name, - display_name=None, - workload=None, + workload, billing_scope=None, + display_name=None, subscription_id=None, no_wait=False): properties = { From 33dacd019fc0977f70b6845298c551764c1fe813 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Fri, 4 Sep 2020 22:08:53 +0800 Subject: [PATCH 08/12] add experimental tag --- src/account/azext_account/generated/_help.py | 4 ++-- src/account/azext_account/generated/commands.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 1409fc73959..497aa171312 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -70,7 +70,7 @@ helps['account tenant'] = """ type: group - short-summary: account tenant + short-summary: Manage tenant """ helps['account tenant list'] = """ @@ -84,7 +84,7 @@ helps['account alias'] = """ type: group - short-summary: account alias + short-summary: Manage subscription alias """ helps['account alias list'] = """ diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index 2e350cd0e3d..39a88ddf5f4 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -16,7 +16,7 @@ def load_command_table(self, _): account_subscription = CliCommandType( operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}', client_factory=cf_subscription) - with self.command_group('account subscription', account_subscription, client_factory=cf_subscription) as g: + with self.command_group('account subscription', account_subscription, client_factory=cf_subscription, is_experimental=True) as g: # g.custom_command('create', 'account_subscription_create_subscription', supports_no_wait=True) g.custom_command('rename', 'account_subscription_rename') g.custom_command('cancel', 'account_subscription_cancel', confirmation=True) From 3c0b4106b632273cc05297ac9d356be7c2ac329f Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Tue, 8 Sep 2020 14:02:30 +0800 Subject: [PATCH 09/12] address comments --- .../generated/_client_factory.py | 6 --- src/account/azext_account/generated/_help.py | 6 +-- .../azext_account/generated/_params.py | 16 +++--- .../azext_account/generated/commands.py | 3 -- src/account/azext_account/generated/custom.py | 52 ------------------- 5 files changed, 11 insertions(+), 72 deletions(-) diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index 89637e56536..3ded7eafb49 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -15,12 +15,6 @@ def cf_account(cli_ctx, *_): def cf_subscription(cli_ctx, *_): return cf_account(cli_ctx).subscription -# def cf_subscription_operation(cli_ctx, *_): -# return cf_account(cli_ctx).subscription_operation - - -# def cf_operation(cli_ctx, *_): -# return cf_account(cli_ctx).operation def cf_tenant(cli_ctx, *_): return cf_account(cli_ctx).tenant diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 497aa171312..c92fe766edf 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -55,7 +55,7 @@ examples: - name: getSubscription text: |- - az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" + az account subscription show --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" """ helps['account subscription list-location'] = """ @@ -65,7 +65,7 @@ examples: - name: listLocations text: |- - az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" + az account subscription list-location --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" """ helps['account tenant'] = """ @@ -112,7 +112,7 @@ - name: CreateAlias text: |- az account alias create --name "aliasForNewSub" --billing-scope "/providers/Microsoft.Billing/billingAcc\ -ounts/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG\ +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" """ diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index 264ea7e7bd6..03eba5b0461 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -13,23 +13,23 @@ def load_arguments(self, _): with self.argument_context('account subscription rename') as c: - c.argument('subscription_id', help='Subscription Id.') + 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', help='Subscription Id.') + 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', help='Subscription Id.') + 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', help='The ID of the target subscription.', id_part='subscription') + c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.', id_part='subscription') with self.argument_context('account subscription list-location') as c: - c.argument('subscription_id', help='The ID of the target subscription.') + c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.') with self.argument_context('account tenant list') as c: pass @@ -41,14 +41,14 @@ def load_arguments(self, _): 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', '--alias-name'], type=str, help='Alias Name') + 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='Determines whether subscription is fieldLed, partnerLed or ' + 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') + 'subscription ID') with self.argument_context('account alias delete') as c: c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index 39a88ddf5f4..24fcc3ed2e4 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -17,12 +17,9 @@ def load_command_table(self, _): operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}', client_factory=cf_subscription) with self.command_group('account subscription', account_subscription, client_factory=cf_subscription, is_experimental=True) as g: - # g.custom_command('create', 'account_subscription_create_subscription', supports_no_wait=True) g.custom_command('rename', 'account_subscription_rename') g.custom_command('cancel', 'account_subscription_cancel', confirmation=True) g.custom_command('enable', 'account_subscription_enable') - # g.custom_command('create-csp', 'account_subscription_create_csp_subscription', supports_no_wait=True) - # g.custom_command('create-in-enrollment-account', 'account_subscription_create_subscription_in_enrollment_account', supports_no_wait=True) g.custom_command('list', 'account_subscription_list') g.custom_show_command('show', 'account_subscription_show') g.custom_command('list-location', 'account_subscription_list_location') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 3781682efae..5faa29a4d6f 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -11,58 +11,6 @@ from azure.cli.core.util import sdk_no_wait -# def account_subscription_create_subscription(cmd, client, -# billing_account_name, -# billing_profile_name, -# invoice_section_name, -# display_name, -# sku_id, -# cost_center=None, -# owner=None, -# management_group_id=None, -# no_wait=False): - -# body = {} -# body['display_name'] = display_name -# body['sku_id'] = sku_id -# body['cost_center'] = cost_center -# body['owner'] = {'object_id': owner} -# body['management_group_id'] = management_group_id -# return sdk_no_wait(no_wait, client.create_subscription, billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, body=body) - - -# def account_subscription_create_subscription_in_enrollment_account(cmd, client, -# enrollment_account_name, -# display_name=None, -# management_group_id=None, -# owners=None, -# offer_type=None, -# no_wait=False): -# if owners is not None: -# owners = [{'object_id': x} for x in owners] - -# body = {} -# body['display_name'] = display_name -# body['management_group_id'] = management_group_id -# body['owners'] = owners -# body['offer_type'] = offer_type -# return sdk_no_wait(no_wait, client.create_subscription_in_enrollment_account, enrollment_account_name=enrollment_account_name, body=body) - - -# def account_subscription_create_csp_subscription(cmd, client, -# billing_account_name, -# customer_name, -# display_name, -# sku_id, -# reseller_id=None, -# no_wait=False): -# body = {} -# body['display_name'] = display_name -# body['sku_id'] = sku_id -# body['reseller_id'] = reseller_id -# return sdk_no_wait(no_wait, client.create_csp_subscription, billing_account_name=billing_account_name, customer_name=customer_name, body=body) - - def account_subscription_rename(cmd, client, subscription_id, subscription_name=None): return client.rename(subscription_id=subscription_id, subscription_name=subscription_name) From 573b53ea33e8d12b19456157dc255e85348f6ff9 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Tue, 8 Sep 2020 14:41:36 +0800 Subject: [PATCH 10/12] modify code owner --- .github/CODEOWNERS | 2 +- src/account/HISTORY.rst | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a1465ee32b7..b61d1c757ae 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -116,7 +116,7 @@ /src/import-export/ @arrownj -/src/account/ @zikalino +/src/account/ @arrownj @jiasli @fengzhou-msft /src/datashare/ @fengzhou-msft diff --git a/src/account/HISTORY.rst b/src/account/HISTORY.rst index b8161021ab7..f609ea48b2d 100644 --- a/src/account/HISTORY.rst +++ b/src/account/HISTORY.rst @@ -5,9 +5,10 @@ Release History 0.2.0 +++++ -* Breaking Change: remove `az account subscription create` -* Add az account alias commands -* Add az account tenant commands +* Breaking Change: remove `az account subscription create`. +* Add az account alias commands. +* Add az account tenant commands. +* Support sovereign clouds. 0.1.0 ++++++ From a9b52c8bb2f70958e7a18ce72925afe6695e69bf Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Wed, 9 Sep 2020 14:54:22 +0800 Subject: [PATCH 11/12] make workload optional --- .../azext_account/generated/_validators.py | 5 +- src/account/azext_account/generated/custom.py | 2 +- .../tests/latest/recordings/test_account.yaml | 52 +++++++++++++++++++ .../tests/latest/test_account_scenario.py | 16 +++--- .../subscription/models/_models.py | 4 -- .../subscription/models/_models_py3.py | 4 -- 6 files changed, 63 insertions(+), 20 deletions(-) diff --git a/src/account/azext_account/generated/_validators.py b/src/account/azext_account/generated/_validators.py index 2d25970eeef..798183f12a4 100644 --- a/src/account/azext_account/generated/_validators.py +++ b/src/account/azext_account/generated/_validators.py @@ -11,5 +11,6 @@ def alias_validator(namespace): 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: - raise CLIError('--billing-scope and --display-name are required.') + 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.') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 5faa29a4d6f..96e94c240c4 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -53,7 +53,7 @@ def account_alias_show(client, def account_alias_create(client, alias_name, - workload, + workload=None, billing_scope=None, display_name=None, subscription_id=None, diff --git a/src/account/azext_account/tests/latest/recordings/test_account.yaml b/src/account/azext_account/tests/latest/recordings/test_account.yaml index a473ed8064a..2bfd74fd0e5 100644 --- a/src/account/azext_account/tests/latest/recordings/test_account.yaml +++ b/src/account/azext_account/tests/latest/recordings/test_account.yaml @@ -833,4 +833,56 @@ interactions: status: code: 200 message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - account alias delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -n + User-Agent: + - AZURECLI/2.11.1 azsdk-python-subscriptionclient/unknown Python/3.6.8 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Subscription/aliases/cli_alias_new000002?api-version=2020-09-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Wed, 09 Sep 2020 06:44:43 GMT + expires: + - '-1' + pragma: + - no-cache + request-id: + - a039b443-376d-474b-8433-c7f5c7ba4a76 + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-aspnet-version: + - 4.0.30319 + x-content-type-options: + - nosniff + x-gsm: + - 1.0.0.0 + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK version: 1 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 bd97245328d..f00a99d5c5b 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -53,8 +53,7 @@ def test_account(self): self.cmd('az account subscription cancel --subscription-id {subscription_id} --yes', checks=[self.check('subscriptionId', '{subscription_id}')]) - if self.in_recording: - time.sleep(300) + time.sleep(300) self.cmd('az account subscription show --subscription-id {subscription_id}', checks=[self.check('displayName', '{display_name}'), self.check('state', 'Warned'), @@ -62,8 +61,7 @@ def test_account(self): self.cmd('az account subscription enable --subscription-id {subscription_id}', checks=[self.check('subscriptionId', '{subscription_id}')]) - if self.in_recording: - time.sleep(300) + time.sleep(300) self.cmd('az account subscription show --subscription-id {subscription_id}', checks=[self.check('displayName', '{display_name}'), self.check('state', 'Enabled'), @@ -71,8 +69,8 @@ def test_account(self): self.cmd('az account subscription rename --subscription-id {subscription_id} --name "{new_display_name}"', checks=[self.check('subscriptionId', '{subscription_id}')]) - # if self.in_recording: - # time.sleep(600) + # 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}'), @@ -89,6 +87,6 @@ def test_account(self): checks=[self.check('name', '{new_alias_name}'), self.check('properties.provisioningState', 'Succeeded')]) - # no permission issue - # self.cmd('az account alias delete -n {new_alias_name}', - # checks=[]) + time.sleep(600) + self.cmd('az account alias delete -n {new_alias_name}', + checks=[]) 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 000c020db08..5987788aaf3 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -318,10 +318,6 @@ class PutAliasRequestProperties(msrest.serialization.Model): :type subscription_id: str """ - _validation = { - 'workload': {'required': True}, - } - _attribute_map = { 'display_name': {'key': 'displayName', 'type': 'str'}, 'workload': {'key': 'workload', 'type': 'str'}, diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py b/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py index 3fb26707880..5f0dee7a2cb 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 @@ -341,10 +341,6 @@ class PutAliasRequestProperties(msrest.serialization.Model): :type subscription_id: str """ - _validation = { - 'workload': {'required': True}, - } - _attribute_map = { 'display_name': {'key': 'displayName', 'type': 'str'}, 'workload': {'key': 'workload', 'type': 'str'}, From f1a76629040293e8611b646e5ada20f76e44d3d9 Mon Sep 17 00:00:00 2001 From: Feng Zhou <55177366+fengzhou-msft@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:01:48 +0800 Subject: [PATCH 12/12] Apply suggestions from code review Co-authored-by: Feiyue Yu --- src/account/azext_account/generated/_help.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index c92fe766edf..59e2266ad36 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -42,7 +42,7 @@ helps['account subscription list'] = """ type: command - short-summary: Gets all subscriptions for a tenant. + short-summary: Get all subscriptions for a tenant. examples: - name: listSubscriptions text: |- @@ -51,7 +51,7 @@ helps['account subscription show'] = """ type: command - short-summary: Gets details about a specified subscription. + short-summary: Get details about a specified subscription. examples: - name: getSubscription text: |- @@ -75,7 +75,7 @@ helps['account tenant list'] = """ type: command - short-summary: Gets the tenants for your account. + short-summary: Get the tenants for your account. examples: - name: listTenants text: |-