diff --git a/src/account/HISTORY.rst b/src/account/HISTORY.rst index 1c139576ba0..27f152061e8 100644 --- a/src/account/HISTORY.rst +++ b/src/account/HISTORY.rst @@ -1,8 +1,8 @@ -.. :changelog: - -Release History -=============== - -0.1.0 -++++++ -* Initial release. +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/account/README.rst b/src/account/README.md similarity index 96% rename from src/account/README.rst rename to src/account/README.md index f97748cd85d..6b095d1f34c 100644 --- a/src/account/README.rst +++ b/src/account/README.md @@ -1,5 +1,5 @@ -Microsoft Azure CLI 'account' Extension -========================================== - -This package is for the 'account' extension. -i.e. 'az account' +Microsoft Azure CLI 'account' Extension +========================================== + +This package is for the 'account' extension. +i.e. 'az account' diff --git a/src/account/azext_account/.flake8 b/src/account/azext_account/.flake8 deleted file mode 100644 index 2e3d72769f9..00000000000 --- a/src/account/azext_account/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -exclude = - vendored_sdks diff --git a/src/account/azext_account/__init__.py b/src/account/azext_account/__init__.py index 6d41a06806a..fcf56c9c465 100644 --- a/src/account/azext_account/__init__.py +++ b/src/account/azext_account/__init__.py @@ -1,41 +1,46 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from azure.cli.core import AzCommandsLoader -from azext_account.generated._help import helps # pylint: disable=unused-import - - -class SubscriptionClientCommandsLoader(AzCommandsLoader): - - def __init__(self, cli_ctx=None): - from azure.cli.core.commands import CliCommandType - from azext_account.generated._client_factory import cf_account - account_custom = CliCommandType( - operations_tmpl='azext_account.custom#{}', - client_factory=cf_account) - super(SubscriptionClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=account_custom) - - def load_command_table(self, args): - from azext_account.generated.commands import load_command_table - load_command_table(self, args) - try: - from azext_account.manual.commands import load_command_table as load_command_table_manual - load_command_table_manual(self, args) - except ImportError: - pass - return self.command_table - - def load_arguments(self, command): - from azext_account.generated._params import load_arguments - load_arguments(self, command) - try: - from azext_account.manual._params import load_arguments as load_arguments_manual - load_arguments_manual(self, command) - except ImportError: - pass - - -COMMAND_LOADER_CLS = SubscriptionClientCommandsLoader +# -------------------------------------------------------------------------- +# 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 azure.cli.core import AzCommandsLoader +from azext_account.generated._help import helps # pylint: disable=unused-import + + +class SubscriptionClientCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_account.generated._client_factory import cf_account + account_custom = CliCommandType( + operations_tmpl='azext_account.custom#{}', + client_factory=cf_account) + parent = super(SubscriptionClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=account_custom) + + def load_command_table(self, args): + from azext_account.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_account.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_account.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_account.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = SubscriptionClientCommandsLoader diff --git a/src/account/azext_account/action.py b/src/account/azext_account/action.py index ae52d832feb..a846b2766c4 100644 --- a/src/account/azext_account/action.py +++ b/src/account/azext_account/action.py @@ -1,13 +1,17 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=wildcard-import -# pylint: disable=unused-wildcard-import - -from azext_account.generated.action import * # noqa: F403 -try: - from azext_account.manual.action import * # noqa: F403 -except ImportError: - pass +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/account/azext_account/azext_metadata.json b/src/account/azext_account/azext_metadata.json index 13025150393..7b56fb1e11a 100644 --- a/src/account/azext_account/azext_metadata.json +++ b/src/account/azext_account/azext_metadata.json @@ -1,4 +1,4 @@ -{ - "azext.isExperimental": true, - "azext.minCliCoreVersion": "2.3.1" +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" } \ No newline at end of file diff --git a/src/account/azext_account/custom.py b/src/account/azext_account/custom.py index 928085d9009..7f31674ce96 100644 --- a/src/account/azext_account/custom.py +++ b/src/account/azext_account/custom.py @@ -1,13 +1,17 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=wildcard-import -# pylint: disable=unused-wildcard-import - -from azext_account.generated.custom import * # noqa: F403 -try: - from azext_account.manual.custom import * # noqa: F403 -except ImportError: - pass +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/account/azext_account/generated/__init__.py b/src/account/azext_account/generated/__init__.py index 34913fb394d..ee0c4f36bd0 100644 --- a/src/account/azext_account/generated/__init__.py +++ b/src/account/azext_account/generated/__init__.py @@ -1,4 +1,12 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index 09cec837dcf..caeee10da79 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -1,24 +1,31 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - - -def cf_account(cli_ctx, *_): - from azure.cli.core.commands.client_factory import _get_mgmt_service_client - from ..vendored_sdks.subscription import SubscriptionClient - return _get_mgmt_service_client(cli_ctx, SubscriptionClient, - subscription_bound=False, - base_url_bound=False)[0] - - -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 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_account(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.subscription import SubscriptionClient + return get_mgmt_service_client(cli_ctx, SubscriptionClient) + + +def cf_subscription(cli_ctx, *_): + return cf_account(cli_ctx).subscription + + +def cf_tenant(cli_ctx, *_): + return cf_account(cli_ctx).tenant + + +def cf_subscription(cli_ctx, *_): + return cf_account(cli_ctx).subscription + + +def cf_subscription_operation(cli_ctx, *_): + return cf_account(cli_ctx).subscription_operation diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 3a23cb4c683..9e326f73254 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -1,80 +1,202 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long -# pylint: disable=too-many-lines - -from knack.help_files import helps - - -helps['account subscription'] = """ - type: group - short-summary: Manage subscriptions -""" - -helps['account subscription create'] = """ - type: command - short-summary: Create a new WebDirect or EA Azure subscription. - examples: - - name: Create 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" -""" - - -helps['account subscription create-in-enrollment-account'] = """ - type: command - short-summary: Create subscription in enrolment account - examples: - - name: Create subscription in enrollment account - 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" -""" - -helps['account subscription create-csp'] = """ - type: command - short-summary: Create a new CSP subscription. - examples: - - name: Create CSP subscription - 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" -""" - -helps['account subscription rename'] = """ - type: command - short-summary: Rename subscription - examples: - - name: Rename subscription - text: |- - 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 enable'] = """ - type: command - short-summary: Enable subscription - examples: - - name: Enable subscription - text: |- - az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -""" +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['account subscription'] = """ + type: group + short-summary: account subscription +""" + +helps['account subscription list'] = """ + type: command + short-summary: Gets all subscriptions for a tenant. + examples: + - name: listSubscriptions + text: |- + az account subscription list +""" + +helps['account subscription show'] = """ + type: command + short-summary: Gets details about a specified subscription. + examples: + - name: getSubscription + text: |- + az account subscription show --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +""" + +helps['account subscription list-location'] = """ + type: command + short-summary: This operation provides all the locations that are available for resource providers; however, each r\ +esource provider may support a subset of this list. + examples: + - name: listLocations + text: |- + az account subscription list-location --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +""" + +helps['account tenant'] = """ + type: group + short-summary: account tenant +""" + +helps['account tenant list'] = """ + type: command + short-summary: Gets the tenants for your account. + examples: + - name: listTenants + text: |- + az account tenant list +""" + +helps['account subscription'] = """ + type: group + short-summary: account subscription +""" + +helps['account subscription 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-type=XX billing-scope=XX subscription-id=XX + + display-name: Required. The friendly name of the subscription. + workload-type: 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 subscription create --alias-name "aliasForNewSub" --properties billing-scope="/providers/Micr\ +osoft.Billing/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/bill\ +ingProfiles/PE2Q-NOIT-BG7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload-type=\ +"Production" +""" + +helps['account subscription delete'] = """ + type: command + short-summary: Delete Alias. + examples: + - name: DeleteAlias + text: |- + az account subscription delete --alias-name "aliasForNewSub" +""" + +helps['account subscription cancel'] = """ + type: command + short-summary: The operation to cancel a subscription + examples: + - name: cancelSubscription + text: |- + az account subscription cancel --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad" +""" + +helps['account subscription create-csp-subscription'] = """ + type: command + short-summary: The operation to create a new CSP subscription. + examples: + - name: createSubscription + text: |- + az account subscription create-csp-subscription --billing-account-name "2bc54a6f-8d8a-5be1-5bff-bb4f285f\ +512b:11a72812-d9a4-446e-9a1e-70c8bcadf5c0_2019-05-31" --display-name "Contoso MCA subscription" --sku-id "0001" --custo\ +mer-name "e33ba30d-3718-4b15-bfaa-5627a57cda6f" +""" + +helps['account subscription create-subscription'] = """ + type: command + short-summary: The operation to create a new WebDirect or EA Azure subscription. + examples: + - name: createSubscription + text: |- + az account subscription create-subscription --billing-account-name "0aa27f2b-ec7f-5a65-71f6-a5ff0897bd55\ +:ae0dae1e-de9a-41f6-8257-76b055d98372_2019-05-31" --billing-profile-name "27VR-HDWX-BG7-TGB" --additional-parameters "{\ +\\"customData\\":{\\"key1\\":\\"value1\\",\\"key2\\":true}}" --cost-center "135366376" --display-name "Contoso MCA subs\ +cription" --owner-object-id "973034ff-acb7-409c-b731-e789672c7b32" --sku-id "0001" --invoice-section-name "JGF7-NSBG-PJ\ +A-TGB" +""" + +helps['account subscription create-subscription-in-enrollment-account'] = """ + type: command + short-summary: Creates an Azure subscription + parameters: + - name: --owners + short-summary: The list of principals that should be granted Owner access on the subscription. Principals shoul\ +d be of type User, Service Principal or Security Group. + long-summary: | + Usage: --owners object-id=XX + + object-id: Required. Object id of the Principal + + Multiple actions can be specified by using more than one --owners argument. + examples: + - name: createSubscription + text: |- + az account subscription create-subscription-in-enrollment-account --additional-parameters "{\\"customDat\ +a\\":{\\"key1\\":\\"value1\\",\\"key2\\":true}}" --display-name "Test Ea Azure Sub" --offer-type "MS-AZR-0017P" --owner\ +s object-id="973034ff-acb7-409c-b731-e789672c7b31" --owners object-id="67439a9e-8519-4016-a630-f5f805eba567" --enrollme\ +nt-account-name "73f8ab6e-cfa0-42be-b886-be6e77c2980c" +""" + +helps['account subscription enable'] = """ + type: command + short-summary: The operation to enable a subscription + examples: + - name: enableSubscription + text: |- + az account subscription enable --subscription-id "7948bcee-488c-47ce-941c-38e20ede803d" +""" + +helps['account subscription get-alias'] = """ + type: command + short-summary: Get Alias Subscription. + examples: + - name: GetAlias + text: |- + az account subscription get-alias --alias-name "aliasForNewSub" +""" + +helps['account subscription list-alias'] = """ + type: command + short-summary: Get Alias Subscription. + examples: + - name: GetAlias + text: |- + az account subscription list-alias +""" + +helps['account subscription rename'] = """ + type: command + short-summary: The operation to rename a subscription + examples: + - name: renameSubscription + text: |- + az account subscription rename --name "Test Sub" --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad\ +" +""" + +helps['account subscription-operation'] = """ + type: group + short-summary: account subscription-operation +""" + +helps['account subscription-operation show'] = """ + type: command + short-summary: Get the status of the pending Microsoft.Subscription API operations. + examples: + - name: getPendingSubscriptionOperations + text: |- + az account subscription-operation show --operation-id "e4b8d068-f574-462a-a76f-6fa0afc613c9" +""" diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index 2f43fd76d28..293fc624581 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -1,48 +1,103 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long -# pylint: disable=too-many-lines -# pylint: disable=too-many-statements - -from azure.cli.core.commands.parameters import ( - get_enum_type -) - - -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') - - with self.argument_context('account subscription cancel') as c: - c.argument('subscription_id', help='Subscription Id.') - - with self.argument_context('account subscription enable') as c: - c.argument('subscription_id', help='Subscription Id.') +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.arguments import CLIArgumentType +from azure.cli.core.commands.parameters import get_enum_type +from azext_account.action import ( + AddProperties, + AddOwners +) + + +def load_arguments(self, _): + + 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 subscription create') as c: + c.argument('alias_name', help='Alias Name') + c.argument('properties', action=AddProperties, nargs='+', help='Put alias request properties.') + + with self.argument_context('account subscription delete') as c: + c.argument('alias_name', help='Alias Name') + + with self.argument_context('account subscription cancel') as c: + c.argument('subscription_id', help='Subscription Id.', id_part='subscription') + + with self.argument_context('account subscription create-csp-subscription') 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 ag' + 'reement 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 create-subscription') 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 w' + 'ant to create the subscription.') + c.argument('invoice_section_name', help='The name of the invoice section in the billing account for which you w' + 'ant 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 ag' + 'reement 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('management_group_id', help='The identifier of the management group to which this subscription will ' + 'be associated.') + c.argument('additional_parameters', arg_type=CLIArgumentType(options_list=['--additional-parameters'], help='Ad' + 'ditional, untyped parameters to support custom subscription creation scenarios. Expected value: jso' + 'n-string/@json-file.')) + c.argument('owner_object_id', help='Object id of the Principal') + + with self.argument_context('account subscription create-subscription-in-enrollment-account') as c: + c.argument('enrollment_account_name', help='The name of the enrollment account to which the subscription will b' + 'e 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', action=AddOwners, nargs='+', help='The list of principals that should be granted Owner acc' + 'ess 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.') + c.argument('additional_parameters', arg_type=CLIArgumentType(options_list=['--additional-parameters'], help='Ad' + 'ditional, untyped parameters to support custom subscription creation scenarios. Expected value: jso' + 'n-string/@json-file.')) + + with self.argument_context('account subscription enable') as c: + c.argument('subscription_id', help='Subscription Id.', id_part='subscription') + + with self.argument_context('account subscription get-alias') as c: + c.argument('alias_name', help='Alias Name') + + with self.argument_context('account subscription list-alias') as c: + pass + + with self.argument_context('account subscription rename') as c: + c.argument('subscription_id', help='Subscription Id.', id_part='subscription') + c.argument('subscription_name', options_list=['--name', '-n'], help='New subscription name') + + with self.argument_context('account subscription-operation show') as c: + c.argument('operation_id', help='The operation ID, which can be found from the Location field in the generate r' + 'ecommendation response header.') diff --git a/src/account/azext_account/generated/_validators.py b/src/account/azext_account/generated/_validators.py index 34913fb394d..e5ac7838677 100644 --- a/src/account/azext_account/generated/_validators.py +++ b/src/account/azext_account/generated/_validators.py @@ -1,4 +1,9 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/account/azext_account/generated/action.py b/src/account/azext_account/generated/action.py index 34913fb394d..657166c8a9b 100644 --- a/src/account/azext_account/generated/action.py +++ b/src/account/azext_account/generated/action.py @@ -1,4 +1,64 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from knack.util import CLIError +from collections import defaultdict + + +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-type': + d['workload_type'] = v[0] + elif kl == 'billing-scope': + d['billing_scope'] = v[0] + elif kl == 'subscription-id': + d['subscription_id'] = v[0] + return d + + +class AddOwners(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddOwners, self).__call__(parser, namespace, action, option_string) + + 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 == 'object-id': + d['object_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..b55d682dc45 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -1,25 +1,60 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=line-too-long -# pylint: disable=too-many-lines -# pylint: disable=too-many-statements -# pylint: disable=too-many-locals -from azure.cli.core.commands import CliCommandType - - -def load_command_table(self, _): - - from azext_account.generated._client_factory import cf_subscription - account_subscription = CliCommandType( - operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}', - 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('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) +# -------------------------------------------------------------------------- +# 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 azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_account.generated._client_factory import cf_subscription + account_subscription = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOpera' + 'tions.{}', + client_factory=cf_subscription) + with self.command_group('account subscription', account_subscription, client_factory=cf_subscription, + is_experimental=True) as g: + g.custom_command('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_subscription + account_subscription = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOpera' + 'tions.{}', + client_factory=cf_subscription) + with self.command_group('account subscription', account_subscription, client_factory=cf_subscription, + is_experimental=True) as g: + g.custom_command('create', 'account_subscription_create') + g.custom_command('delete', 'account_subscription_delete') + g.custom_command('cancel', 'account_subscription_cancel') + g.custom_command('create-csp-subscription', 'account_subscription_create_csp_subscription') + g.custom_command('create-subscription', 'account_subscription_create_subscription') + g.custom_command('create-subscription-in-enrollment-account', 'account_subscription_create_subscription_in_enro' + 'llment_account') + g.custom_command('enable', 'account_subscription_enable') + g.custom_command('get-alias', 'account_subscription_get_alias') + g.custom_command('list-alias', 'account_subscription_list_alias') + g.custom_command('rename', 'account_subscription_rename') + + from azext_account.generated._client_factory import cf_subscription_operation + account_subscription_operation = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operation_operations#Subscri' + 'ptionOperationOperations.{}', + client_factory=cf_subscription_operation) + with self.command_group('account subscription-operation', account_subscription_operation, + client_factory=cf_subscription_operation, is_experimental=True) as g: + g.custom_show_command('show', 'account_subscription_operation_show') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index ccdcccb94f1..ef9ff0c32d0 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -1,76 +1,126 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- -# pylint: disable=line-too-long -# pylint: disable=too-many-statements -# pylint: disable=too-many-lines -# pylint: disable=too-many-locals -# pylint: disable=unused-argument - -from azure.cli.core.util import sdk_no_wait - - -def account_subscription_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) - - -def account_subscription_cancel(cmd, client, subscription_id): - return client.cancel(subscription_id=subscription_id) - - -def account_subscription_enable(cmd, client, subscription_id): - return client.enable(subscription_id=subscription_id) +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +import json + + +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_subscription_create(client, + alias_name, + properties=None): + return client.begin_create_alias(alias_name=alias_name, + properties=properties) + + +def account_subscription_delete(client, + alias_name): + return client.delete_alias(alias_name=alias_name) + + +def account_subscription_cancel(client, + subscription_id): + return client.cancel(subscription_id=subscription_id) + + +def account_subscription_create_csp_subscription(client, + billing_account_name, + customer_name, + display_name, + sku_id, + reseller_id=None): + return client.begin_create_csp_subscription(billing_account_name=billing_account_name, + customer_name=customer_name, + display_name=display_name, + sku_id=sku_id, + reseller_id=reseller_id) + + +def account_subscription_create_subscription(client, + billing_account_name, + billing_profile_name, + invoice_section_name, + display_name, + sku_id, + cost_center=None, + management_group_id=None, + additional_parameters=None, + owner_object_id=None): + if isinstance(additional_parameters, str): + additional_parameters = json.loads(additional_parameters) + return client.begin_create_subscription(billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + display_name=display_name, + sku_id=sku_id, + cost_center=cost_center, + management_group_id=management_group_id, + additional_parameters=additional_parameters, + object_id=owner_object_id) + + +def account_subscription_create_subscription_in_enrollment_account(client, + enrollment_account_name, + display_name=None, + management_group_id=None, + owners=None, + offer_type=None, + additional_parameters=None): + if isinstance(additional_parameters, str): + additional_parameters = json.loads(additional_parameters) + return client.begin_create_subscription_in_enrollment_account(enrollment_account_name=enrollment_account_name, + display_name=display_name, + management_group_id=management_group_id, + owners=owners, + offer_type=offer_type, + additional_parameters=additional_parameters) + + +def account_subscription_enable(client, + subscription_id): + return client.enable(subscription_id=subscription_id) + + +def account_subscription_get_alias(client, + alias_name): + return client.get_alias(alias_name=alias_name) + + +def account_subscription_list_alias(client): + return client.list_alias() + + +def account_subscription_rename(client, + subscription_id, + subscription_name=None): + return client.rename(subscription_id=subscription_id, + subscription_name=subscription_name) + + +def account_subscription_operation_show(client, + operation_id): + return client.get(operation_id=operation_id) diff --git a/src/account/azext_account/vendored_sdks/subscription/version.py b/src/account/azext_account/manual/__init__.py similarity index 86% rename from src/account/azext_account/vendored_sdks/subscription/version.py rename to src/account/azext_account/manual/__init__.py index 266f5a486d7..ee0c4f36bd0 100644 --- a/src/account/azext_account/vendored_sdks/subscription/version.py +++ b/src/account/azext_account/manual/__init__.py @@ -1,13 +1,12 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "0.5.0" - +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/tests/__init__.py b/src/account/azext_account/tests/__init__.py new file mode 100644 index 00000000000..5f8f1fd97ad --- /dev/null +++ b/src/account/azext_account/tests/__init__.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import os +import sys +import traceback +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + print("Found manual override for {}(...)".format(func.__name__)) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + print("running {}()...".format(func.__name__)) + try: + return func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e: + print("--------------------------------------") + print("step exception: ", e) + print("--------------------------------------", file=sys.stderr) + print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr) + traceback.print_exc() + exceptions.append((func.__name__, sys.exc_info())) + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/account/azext_account/tests/latest/__init__.py b/src/account/azext_account/tests/latest/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/account/azext_account/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/tests/latest/preparers.py b/src/account/azext_account/tests/latest/preparers.py new file mode 100644 index 00000000000..4702355b2bd --- /dev/null +++ b/src/account/azext_account/tests/latest/preparers.py @@ -0,0 +1,159 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' +KEY_VNET_NIC = 'nic' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --subnet-name default --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + pass + + +class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.nic', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', + key=KEY_VNET_NIC): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetNicPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group[1], name, self.vnet[1])) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1])) diff --git a/src/account/azext_account/tests/latest/test_account_scenario.py b/src/account/azext_account/tests/latest/test_account_scenario.py index 92d77b58d79..6bc8dbbc8f3 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -1,101 +1,194 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -import os -import unittest - -from azure_devtools.scenario_tests import AllowLargeResponse -from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) - - -TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) - - -class SubscriptionClientScenarioTest(ScenarioTest): - - @ResourceGroupPreparer(name_prefix='cli_test_account') - def test_account(self, 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"', - 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', - checks=[]) +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test): + pass + + +# EXAMPLE: /Subscription/put/CreateAlias +@try_manual +def step__subscription_put_createalias(test): + test.cmd('az account subscription create ' + '--alias-name "aliasForNewSub" ' + '--properties billing-scope="/providers/Microsoft.Billing/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc986' + '8693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG7-TGB/invoiceSections/MT' + 'T4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload-type="Production"', + checks=[]) + + +# EXAMPLE: /Subscription/get/GetAlias +@try_manual +def step__subscription_get_getalias(test): + test.cmd('az account subscription get-alias ' + '--alias-name "aliasForNewSub"', + checks=[]) + + +# EXAMPLE: /Subscription/get/GetAlias +@try_manual +def step__subscription_get_getalias(test): + test.cmd('az account subscription get-alias ' + '--alias-name "aliasForNewSub"', + checks=[]) + + +# EXAMPLE: /Subscription/post/cancelSubscription +@try_manual +def step__subscription_post_cancelsubscription(test): + test.cmd('az account subscription cancel ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscription/post/createSubscription +@try_manual +def step__subscription_post_createsubscription(test): + test.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=[]) + + +# EXAMPLE: /Subscription/post/createSubscription +@try_manual +def step__subscription_post_createsubscription(test): + test.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=[]) + + +# EXAMPLE: /Subscription/post/createSubscription +@try_manual +def step__subscription_post_createsubscription(test): + test.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=[]) + + +# EXAMPLE: /Subscription/post/enableSubscription +@try_manual +def step__subscription_post_enablesubscription(test): + test.cmd('az account subscription enable ' + '--subscription-id "7948bcee-488c-47ce-941c-38e20ede803d"', + checks=[]) + + +# EXAMPLE: /Subscription/post/renameSubscription +@try_manual +def step__subscription_post_renamesubscription(test): + test.cmd('az account subscription rename ' + '--name "{Test Sub}" ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /SubscriptionOperation/get/getPendingSubscriptionOperations +@try_manual +def step__subscriptionoperation_get_getpendingsubscriptionoperations(test): + test.cmd('az account subscription-operation show ' + '--operation-id "e4b8d068-f574-462a-a76f-6fa0afc613c9"', + checks=[]) + + +# EXAMPLE: /Subscriptions/get/getSubscription +@try_manual +def step__subscriptions_get_getsubscription(test): + test.cmd('az account subscription show ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscriptions/get/listLocations +@try_manual +def step__subscriptions_get_listlocations(test): + test.cmd('az account subscription list-location ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', + checks=[]) + + +# EXAMPLE: /Subscriptions/get/listSubscriptions +@try_manual +def step__subscriptions_get_listsubscriptions(test): + test.cmd('az account subscription list', + checks=[]) + + +# EXAMPLE: /Tenants/get/listTenants +@try_manual +def step__tenants_get_listtenants(test): + test.cmd('az account tenant list', + checks=[]) + + +# EXAMPLE: /Subscription/delete/DeleteAlias +@try_manual +def step__subscription_delete_deletealias(test): + test.cmd('az account subscription delete ' + '--alias-name "aliasForNewSub"', + checks=[]) + + +@try_manual +def cleanup(test): + pass + + +@try_manual +def call_scenario(test): + setup(test) + step__subscription_put_createalias(test) + step__subscription_get_getalias(test) + step__subscription_get_getalias(test) + step__subscription_post_cancelsubscription(test) + step__subscription_post_createsubscription(test) + step__subscription_post_createsubscription(test) + step__subscription_post_createsubscription(test) + step__subscription_post_enablesubscription(test) + step__subscription_post_renamesubscription(test) + step__subscriptionoperation_get_getpendingsubscriptionoperations(test) + step__subscriptions_get_getsubscription(test) + step__subscriptions_get_listlocations(test) + step__subscriptions_get_listsubscriptions(test) + step__tenants_get_listtenants(test) + step__subscription_delete_deletealias(test) + cleanup(test) + + +@try_manual +class SubscriptionClientScenarioTest(ScenarioTest): + + def test_account(self): + + self.kwargs.update({ + 'Test Sub': 'Test Sub', + }) + + call_scenario(self) + raise_if() diff --git a/src/account/azext_account/vendored_sdks/__init__.py b/src/account/azext_account/vendored_sdks/__init__.py index be1a152630c..ee0c4f36bd0 100644 --- a/src/account/azext_account/vendored_sdks/__init__.py +++ b/src/account/azext_account/vendored_sdks/__init__.py @@ -1,12 +1,12 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/account/azext_account/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..bb5dc2e56ad 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,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. -# +# 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 TenantOperations +from .operations import SubscriptionOperations from .operations import SubscriptionOperationOperations -from .operations import Operations +from .operations import OperationOperations 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 subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.operations.SubscriptionOperations + :ivar subscription_operation: SubscriptionOperationOperations operations + :vartype subscription_operation: subscription_client.operations.SubscriptionOperationOperations + :ivar operation: OperationOperations operations + :vartype operation: subscription_client.operations.OperationOperations + :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._client, self._config, self._serialize, self._deserialize) + self.tenant = TenantOperations( + self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) self.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.operation = OperationOperations( + 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..efe36b5d4ab --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py @@ -0,0 +1,80 @@ +# 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 SubscriptionOperations +from .operations_async import SubscriptionOperationOperations +from .operations_async import OperationOperations +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 subscription: SubscriptionOperations operations + :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations + :ivar subscription_operation: SubscriptionOperationOperations operations + :vartype subscription_operation: subscription_client.aio.operations_async.SubscriptionOperationOperations + :ivar operation: OperationOperations operations + :vartype operation: subscription_client.aio.operations_async.OperationOperations + :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.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.subscription_operation = SubscriptionOperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + 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..1e970547037 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py @@ -0,0 +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. +# 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 ._subscription_operations_async import SubscriptionOperations +from ._subscription_operation_operations_async import SubscriptionOperationOperations +from ._operation_operations_async import OperationOperations + +__all__ = [ + 'SubscriptionOperations', + 'TenantOperations', + 'SubscriptionOperations', + 'SubscriptionOperationOperations', + 'OperationOperations', +] 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..8bb168bfe67 --- /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 = "2019-10-01-preview" + + # 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_operation_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operation_operations_async.py new file mode 100644 index 00000000000..95e060c4876 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operation_operations_async.py @@ -0,0 +1,100 @@ +# 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 SubscriptionOperationOperations: + """SubscriptionOperationOperations 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 get( + self, + operation_id: str, + **kwargs + ) -> "models.SubscriptionCreationResult": + """Get the status of the pending Microsoft.Subscription API operations. + + :param operation_id: The operation ID, which can be found from the Location field in the + generate recommendation response header. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionCreationResult, or the result of cls(response) + :rtype: ~subscription_client.models.SubscriptionCreationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/subscriptionOperations/{operationId}'} # 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..20b5753db7e --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py @@ -0,0 +1,877 @@ +# 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, List, 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 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 + + async def _create_subscription_in_enrollment_account_initial( + self, + enrollment_account_name: str, + display_name: Optional[str] = None, + management_group_id: Optional[str] = None, + owners: Optional[List["models.AdPrincipal"]] = None, + offer_type: Optional[Union[str, "models.OfferType"]] = None, + additional_parameters: Optional[Dict[str, object]] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.SubscriptionCreationParameters(display_name=display_name, management_group_id=management_group_id, owners=owners, offer_type=offer_type, additional_parameters=additional_parameters) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_subscription_in_enrollment_account_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'enrollmentAccountName': self._serialize.url("enrollment_account_name", enrollment_account_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, 'SubscriptionCreationParameters') + 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, 202]: + 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) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_subscription_in_enrollment_account_initial.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + async def create_subscription_in_enrollment_account( + self, + enrollment_account_name: str, + display_name: Optional[str] = None, + management_group_id: Optional[str] = None, + owners: Optional[List["models.AdPrincipal"]] = None, + offer_type: Optional[Union[str, "models.OfferType"]] = None, + additional_parameters: Optional[Dict[str, object]] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + """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 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[~subscription_client.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. + :type offer_type: str or ~subscription_client.models.OfferType + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :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: SubscriptionCreationResult, or the result of cls(response) + :rtype: ~subscription_client.models.SubscriptionCreationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_subscription_in_enrollment_account_initial( + enrollment_account_name=enrollment_account_name, + display_name=display_name, + management_group_id=management_group_id, + owners=owners, + offer_type=offer_type, + additional_parameters=additional_parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('SubscriptionCreationResult', 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_subscription_in_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} # 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 = "2019-10-01-preview" + + # 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 = "2019-10-01-preview" + 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 = "2019-10-01-preview" + + # 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 + + async def _create_subscription_initial( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + display_name: str, + sku_id: str, + cost_center: Optional[str] = None, + management_group_id: Optional[str] = None, + additional_parameters: Optional[Dict[str, object]] = None, + object_id: Optional[str] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.ModernSubscriptionCreationParameters(display_name=display_name, sku_id=sku_id, cost_center=cost_center, management_group_id=management_group_id, additional_parameters=additional_parameters, object_id=object_id) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_subscription_initial.metadata['url'] # type: ignore + 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 = {} # 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, 'ModernSubscriptionCreationParameters') + 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, 202]: + 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) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_subscription_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + async def create_subscription( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + display_name: str, + sku_id: str, + cost_center: Optional[str] = None, + management_group_id: Optional[str] = None, + additional_parameters: Optional[Dict[str, object]] = None, + object_id: Optional[str] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + """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 display_name: The friendly name of the subscription. + :type display_name: str + :param sku_id: 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 management_group_id: The identifier of the management group to which this subscription + will be associated. + :type management_group_id: str + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :param object_id: Object id of the Principal. + :type object_id: str + :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: SubscriptionCreationResult, or the result of cls(response) + :rtype: ~subscription_client.models.SubscriptionCreationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_subscription_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + display_name=display_name, + sku_id=sku_id, + cost_center=cost_center, + management_group_id=management_group_id, + additional_parameters=additional_parameters, + object_id=object_id, + 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('SubscriptionCreationResult', 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_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + async def _create_csp_subscription_initial( + self, + billing_account_name: str, + customer_name: str, + display_name: str, + sku_id: str, + reseller_id: Optional[str] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.ModernCspSubscriptionCreationParameters(display_name=display_name, sku_id=sku_id, reseller_id=reseller_id) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_csp_subscription_initial.metadata['url'] # type: ignore + 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 = {} # 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, 'ModernCspSubscriptionCreationParameters') + 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, 202]: + 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) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_csp_subscription_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + async def create_csp_subscription( + self, + billing_account_name: str, + customer_name: str, + display_name: str, + sku_id: str, + reseller_id: Optional[str] = None, + **kwargs + ) -> "models.SubscriptionCreationResult": + """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 display_name: The friendly name of the subscription. + :type display_name: str + :param sku_id: 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 + :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: SubscriptionCreationResult, or the result of cls(response) + :rtype: ~subscription_client.models.SubscriptionCreationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_csp_subscription_initial( + billing_account_name=billing_account_name, + customer_name=customer_name, + display_name=display_name, + sku_id=sku_id, + reseller_id=reseller_id, + 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('SubscriptionCreationResult', 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_csp_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + async def _create_alias_initial( + self, + alias_name: str, + properties: Optional["models.PutAliasRequestProperties"] = None, + **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 = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_alias_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_alias_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def create_alias( + self, + alias_name: str, + properties: Optional["models.PutAliasRequestProperties"] = None, + **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_alias_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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def get_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.get_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def delete_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.delete_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def list_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.list_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # 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..17a356e14b8 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,104 @@ # 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 ErrorResponse + from ._models_py3 import ErrorResponseBody + from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import ModernCspSubscriptionCreationParameters from ._models_py3 import ModernSubscriptionCreationParameters 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 Subscription from ._models_py3 import SubscriptionCreationParameters from ._models_py3 import SubscriptionCreationResult + 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 AdPrincipal # type: ignore + 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 ModernCspSubscriptionCreationParameters # type: ignore + from ._models import ModernSubscriptionCreationParameters # 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 SubscriptionCreationParameters # type: ignore + from ._models import SubscriptionCreationResult # 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, + WorkloadType, ) __all__ = [ 'AdPrincipal', 'CanceledSubscriptionId', 'EnabledSubscriptionId', - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', + 'ErrorResponseBody', + 'Location', + 'LocationListResult', 'ModernCspSubscriptionCreationParameters', 'ModernSubscriptionCreationParameters', 'Operation', 'OperationDisplay', 'OperationListResult', + 'PutAliasListResult', + 'PutAliasRequest', + 'PutAliasRequestProperties', + 'PutAliasResponse', + 'PutAliasResponseProperties', 'RenamedSubscriptionId', + 'Subscription', 'SubscriptionCreationParameters', 'SubscriptionCreationResult', + 'SubscriptionListResult', 'SubscriptionName', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', 'OfferType', + 'ProvisioningState', + 'SpendingLimit', + 'SubscriptionState', + 'WorkloadType', ] 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..d30ccd27e4a 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -1,24 +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): +class AdPrincipal(msrest.serialization.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 + :param object_id: Required. Object id of the Principal. :type object_id: str """ @@ -30,18 +27,20 @@ class AdPrincipal(Model): 'object_id': {'key': 'objectId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AdPrincipal, self).__init__(**kwargs) - self.object_id = kwargs.get('object_id', None) + self.object_id = kwargs['object_id'] -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 +52,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 +77,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,35 +99,114 @@ 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): + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + 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 = { + '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'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + } + + 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 ModernCspSubscriptionCreationParameters(Model): +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~subscription_client.models.Location] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class ModernCspSubscriptionCreationParameters(msrest.serialization.Model): """The parameters required to create a new CSP subscription. 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 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. + :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 @@ -148,35 +223,37 @@ class ModernCspSubscriptionCreationParameters(Model): 'reseller_id': {'key': 'resellerId', 'type': 'str'}, } - def __init__(self, **kwargs): + 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.display_name = kwargs['display_name'] + self.sku_id = kwargs['sku_id'] self.reseller_id = kwargs.get('reseller_id', None) -class ModernSubscriptionCreationParameters(Model): +class ModernSubscriptionCreationParameters(msrest.serialization.Model): """The parameters required to create a new subscription. 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 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. + :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. + :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. + :param management_group_id: The identifier of the management group to which this subscription + will be associated. :type management_group_id: str + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :param object_id: Object id of the Principal. + :type object_id: str """ _validation = { @@ -188,26 +265,31 @@ class ModernSubscriptionCreationParameters(Model): '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'}, + 'additional_parameters': {'key': 'additionalParameters', 'type': '{object}'}, + 'object_id': {'key': 'owner.objectId', 'type': 'str'}, } - def __init__(self, **kwargs): + 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.display_name = kwargs['display_name'] + self.sku_id = kwargs['sku_id'] self.cost_center = kwargs.get('cost_center', None) - self.owner = kwargs.get('owner', None) self.management_group_id = kwargs.get('management_group_id', None) + self.additional_parameters = kwargs.get('additional_parameters', None) + self.object_id = kwargs.get('object_id', 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 +297,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 +323,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 +347,181 @@ 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. + + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(PutAliasRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +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_type: Required. The workload type of the subscription. It can be either + Production or DevTest. Possible values include: "Production", "DevTest". + :type workload_type: str or ~subscription_client.models.WorkloadType + :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_type': {'required': True}, + 'billing_scope': {'required': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'workload_type': {'key': 'workloadType', '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_type = kwargs['workload_type'] + 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,29 +533,84 @@ 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. +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, + **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 SubscriptionCreationParameters(msrest.serialization.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 + :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[~subscription_client.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 ~subscription_client.models.OfferType + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] """ _attribute_map = { @@ -316,21 +618,26 @@ class SubscriptionCreationParameters(Model): 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, 'owners': {'key': 'owners', 'type': '[AdPrincipal]'}, 'offer_type': {'key': 'offerType', 'type': 'str'}, + 'additional_parameters': {'key': 'additionalParameters', 'type': '{object}'}, } - def __init__(self, **kwargs): + 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) + self.additional_parameters = kwargs.get('additional_parameters', None) -class SubscriptionCreationResult(Model): +class SubscriptionCreationResult(msrest.serialization.Model): """The created subscription object. - :param subscription_link: The link to the new subscription. Use this link - to check the status of subscription creation operation. + :param subscription_link: The link to the new subscription. Use this link to check the status + of subscription creation operation. :type subscription_link: str """ @@ -338,15 +645,47 @@ class SubscriptionCreationResult(Model): 'subscription_link': {'key': 'subscriptionLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionCreationResult, self).__init__(**kwargs) self.subscription_link = kwargs.get('subscription_link', None) -class SubscriptionName(Model): +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, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['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 +693,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..e455bbd7836 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,24 +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 Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AdPrincipal(Model): +from ._subscription_client_enums import * + + +class AdPrincipal(msrest.serialization.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 + :param object_id: Required. Object id of the Principal. :type object_id: str """ @@ -30,18 +31,22 @@ class AdPrincipal(Model): 'object_id': {'key': 'objectId', 'type': 'str'}, } - def __init__(self, *, object_id: str, **kwargs) -> None: + def __init__( + self, + *, + object_id: str, + **kwargs + ): super(AdPrincipal, self).__init__(**kwargs) self.object_id = object_id -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 +58,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 +83,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,35 +105,121 @@ 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): + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + 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 = { + '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'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + } + + 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 - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) +class LocationListResult(msrest.serialization.Model): + """Location list operation response. -class ModernCspSubscriptionCreationParameters(Model): + :param value: An array of locations. + :type value: list[~subscription_client.models.Location] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class ModernCspSubscriptionCreationParameters(msrest.serialization.Model): """The parameters required to create a new CSP subscription. 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 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. + :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 @@ -148,35 +236,41 @@ class ModernCspSubscriptionCreationParameters(Model): 'reseller_id': {'key': 'resellerId', 'type': 'str'}, } - def __init__(self, *, display_name: str, sku_id: str, reseller_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: str, + sku_id: str, + reseller_id: Optional[str] = None, + **kwargs + ): super(ModernCspSubscriptionCreationParameters, self).__init__(**kwargs) self.display_name = display_name self.sku_id = sku_id self.reseller_id = reseller_id -class ModernSubscriptionCreationParameters(Model): +class ModernSubscriptionCreationParameters(msrest.serialization.Model): """The parameters required to create a new subscription. 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 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. + :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. + :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. + :param management_group_id: The identifier of the management group to which this subscription + will be associated. :type management_group_id: str + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :param object_id: Object id of the Principal. + :type object_id: str """ _validation = { @@ -188,26 +282,38 @@ class ModernSubscriptionCreationParameters(Model): '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'}, + 'additional_parameters': {'key': 'additionalParameters', 'type': '{object}'}, + 'object_id': {'key': 'owner.objectId', 'type': 'str'}, } - def __init__(self, *, display_name: str, sku_id: str, cost_center: str=None, owner=None, management_group_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: str, + sku_id: str, + cost_center: Optional[str] = None, + management_group_id: Optional[str] = None, + additional_parameters: Optional[Dict[str, object]] = None, + object_id: Optional[str] = None, + **kwargs + ): 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 + self.additional_parameters = additional_parameters + self.object_id = object_id -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 +321,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 +350,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,19 +378,195 @@ 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): +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. + + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + } + + def __init__( + self, + *, + properties: Optional["PutAliasRequestProperties"] = None, + **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 workload_type: Required. The workload type of the subscription. It can be either + Production or DevTest. Possible values include: "Production", "DevTest". + :type workload_type: str or ~subscription_client.models.WorkloadType + :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_type': {'required': True}, + 'billing_scope': {'required': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'workload_type': {'key': 'workloadType', 'type': 'str'}, + 'billing_scope': {'key': 'billingScope', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: str, + workload_type: Union[str, "WorkloadType"], + billing_scope: str, + subscription_id: Optional[str] = None, + **kwargs + ): + super(PutAliasRequestProperties, self).__init__(**kwargs) + self.display_name = display_name + self.workload_type = workload_type + 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}, + } + + _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, + *, + 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_id': {'key': 'subscriptionId', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + 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. + 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,29 +578,87 @@ class RenamedSubscriptionId(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + 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. +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 SubscriptionCreationParameters(msrest.serialization.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 + :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[~subscription_client.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 ~subscription_client.models.OfferType + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] """ _attribute_map = { @@ -316,21 +666,32 @@ class SubscriptionCreationParameters(Model): 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, 'owners': {'key': 'owners', 'type': '[AdPrincipal]'}, 'offer_type': {'key': 'offerType', 'type': 'str'}, + 'additional_parameters': {'key': 'additionalParameters', 'type': '{object}'}, } - def __init__(self, *, display_name: str=None, management_group_id: str=None, owners=None, offer_type=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + management_group_id: Optional[str] = None, + owners: Optional[List["AdPrincipal"]] = None, + offer_type: Optional[Union[str, "OfferType"]] = None, + additional_parameters: Optional[Dict[str, object]] = None, + **kwargs + ): super(SubscriptionCreationParameters, self).__init__(**kwargs) self.display_name = display_name self.management_group_id = management_group_id self.owners = owners self.offer_type = offer_type + self.additional_parameters = additional_parameters -class SubscriptionCreationResult(Model): +class SubscriptionCreationResult(msrest.serialization.Model): """The created subscription object. - :param subscription_link: The link to the new subscription. Use this link - to check the status of subscription creation operation. + :param subscription_link: The link to the new subscription. Use this link to check the status + of subscription creation operation. :type subscription_link: str """ @@ -338,15 +699,52 @@ class SubscriptionCreationResult(Model): 'subscription_link': {'key': 'subscriptionLink', 'type': 'str'}, } - def __init__(self, *, subscription_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_link: Optional[str] = None, + **kwargs + ): super(SubscriptionCreationResult, self).__init__(**kwargs) self.subscription_link = subscription_link -class SubscriptionName(Model): +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 +752,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..ecfbbfb0018 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,51 @@ # 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 OfferType(str, Enum): + """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. + """ + + ms_azr0017_p = "MS-AZR-0017P" + ms_azr0148_p = "MS-AZR-0148P" + +class ProvisioningState(str, Enum): + """The provisioning state of the resource. + """ + + accepted = "Accepted" + succeeded = "Succeeded" + failed = "Failed" + +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 WorkloadType(str, Enum): + """The workload type of the subscription. It can be either Production or DevTest. + """ - ms_azr_0017_p = "MS-AZR-0017P" - ms_azr_0148_p = "MS-AZR-0148P" + 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..db6836419be 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,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 ._subscription_operations import SubscriptionOperations +from ._tenant_operations import TenantOperations from ._subscription_operations import SubscriptionOperations from ._subscription_operation_operations import SubscriptionOperationOperations -from ._operations import Operations +from ._operation_operations import OperationOperations __all__ = [ + 'SubscriptionOperations', + 'TenantOperations', 'SubscriptionOperations', 'SubscriptionOperationOperations', - 'Operations', + 'OperationOperations', ] 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..061a0680b2f --- /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 = "2019-10-01-preview" + + # 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/_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py deleted file mode 100644 index 664844824d5..00000000000 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_operations.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse - -from .. import models - - -class Operations(object): - """Operations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Current version is 2019-10-01-preview. Constant value: "2019-10-01-preview". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-10-01-preview" - - self.config = config - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists all of the available Microsoft.Subscription API operations. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OperationListResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.OperationListResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` - """ - # Construct URL - url = self.list.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationListResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py index ff4eaf571ec..226d56683b0 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operation_operations.py @@ -1,104 +1,105 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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 msrestazure.azure_exceptions import CloudError +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 SubscriptionOperationOperations(object): """SubscriptionOperationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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 + self._config = config def get( - self, operation_id, custom_headers=None, raw=False, **operation_config): + self, + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionCreationResult" """Get the status of the pending Microsoft.Subscription API operations. - :param operation_id: The operation ID, which can be found from the - Location field in the generate recommendation response header. + :param operation_id: The operation ID, which can be found from the Location field in the + generate recommendation response header. :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SubscriptionCreationResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.SubscriptionCreationResult or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionCreationResult, or the result of cls(response) + :rtype: ~subscription_client.models.SubscriptionCreationResult or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'operationId': self._serialize.url("operation_id", operation_id, 'str') + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + 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.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - header_dict = {} + response_headers = {} deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - 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, response_headers) return deserialized - get.metadata = {'url': '/providers/Microsoft.Subscription/subscriptionOperations/{operationId}'} + get.metadata = {'url': '/providers/Microsoft.Subscription/subscriptionOperations/{operationId}'} # 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..50361945263 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,895 @@ # 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.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, List, Optional, TypeVar, Union + + 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 - + self._config = config def _create_subscription_in_enrollment_account_initial( - self, enrollment_account_name, body, custom_headers=None, raw=False, **operation_config): + self, + enrollment_account_name, # type: str + display_name=None, # type: Optional[str] + management_group_id=None, # type: Optional[str] + owners=None, # type: Optional[List["models.AdPrincipal"]] + offer_type=None, # type: Optional[Union[str, "models.OfferType"]] + additional_parameters=None, # type: Optional[Dict[str, object]] + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionCreationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.SubscriptionCreationParameters(display_name=display_name, management_group_id=management_group_id, owners=owners, offer_type=offer_type, additional_parameters=additional_parameters) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_subscription_in_enrollment_account.metadata['url'] + url = self._create_subscription_in_enrollment_account_initial.metadata['url'] # type: ignore path_format_arguments = { - 'enrollmentAccountName': self._serialize.url("enrollment_account_name", enrollment_account_name, 'str') + 'enrollmentAccountName': self._serialize.url("enrollment_account_name", enrollment_account_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') + 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, '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) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'SubscriptionCreationParameters') + 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, 202]: - 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) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def create_subscription_in_enrollment_account( - self, enrollment_account_name, body, custom_headers=None, raw=False, polling=True, **operation_config): + return deserialized + _create_subscription_in_enrollment_account_initial.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + def begin_create_subscription_in_enrollment_account( + self, + enrollment_account_name, # type: str + display_name=None, # type: Optional[str] + management_group_id=None, # type: Optional[str] + owners=None, # type: Optional[List["models.AdPrincipal"]] + offer_type=None, # type: Optional[Union[str, "models.OfferType"]] + additional_parameters=None, # type: Optional[Dict[str, object]] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates an Azure subscription. - :param enrollment_account_name: The name of the enrollment account to - which the subscription will be billed. + :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 + :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[~subscription_client.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. + :type offer_type: str or ~subscription_client.models.OfferType + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :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 - :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` + :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 SubscriptionCreationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.SubscriptionCreationResult] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) 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 + display_name=display_name, + management_group_id=management_group_id, + owners=owners, + offer_type=offer_type, + additional_parameters=additional_parameters, + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) 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) + 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) - create_subscription_in_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} + begin_create_subscription_in_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'} # 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 = "2019-10-01-preview" + # 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 = "2019-10-01-preview" + 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 = "2019-10-01-preview" + # 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'} - + enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore def _create_subscription_initial( - self, billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers=None, raw=False, **operation_config): + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + display_name, # type: str + sku_id, # type: str + cost_center=None, # type: Optional[str] + management_group_id=None, # type: Optional[str] + additional_parameters=None, # type: Optional[Dict[str, object]] + object_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionCreationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.ModernSubscriptionCreationParameters(display_name=display_name, sku_id=sku_id, cost_center=cost_center, management_group_id=management_group_id, additional_parameters=additional_parameters, object_id=object_id) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_subscription.metadata['url'] + url = self._create_subscription_initial.metadata['url'] # type: ignore 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') + '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') + 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, '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) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'ModernSubscriptionCreationParameters') + 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, 202]: - 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) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def create_subscription( - self, billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers=None, raw=False, polling=True, **operation_config): + return deserialized + _create_subscription_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + def begin_create_subscription( + self, + billing_account_name, # type: str + billing_profile_name, # type: str + invoice_section_name, # type: str + display_name, # type: str + sku_id, # type: str + cost_center=None, # type: Optional[str] + management_group_id=None, # type: Optional[str] + additional_parameters=None, # type: Optional[Dict[str, object]] + object_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """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. + :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. + :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. + :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 + :param display_name: The friendly name of the subscription. + :type display_name: str + :param sku_id: 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 management_group_id: The identifier of the management group to which this subscription + will be associated. + :type management_group_id: str + :param additional_parameters: Additional, untyped parameters to support custom subscription + creation scenarios. + :type additional_parameters: dict[str, object] + :param object_id: Object id of the Principal. + :type object_id: str + :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 - :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` + :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 SubscriptionCreationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.SubscriptionCreationResult] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) 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 + display_name=display_name, + sku_id=sku_id, + cost_center=cost_center, + management_group_id=management_group_id, + additional_parameters=additional_parameters, + object_id=object_id, + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) 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) + 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) - create_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} - + begin_create_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore def _create_csp_subscription_initial( - self, billing_account_name, customer_name, body, custom_headers=None, raw=False, **operation_config): + self, + billing_account_name, # type: str + customer_name, # type: str + display_name, # type: str + sku_id, # type: str + reseller_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionCreationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.ModernCspSubscriptionCreationParameters(display_name=display_name, sku_id=sku_id, reseller_id=reseller_id) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_csp_subscription.metadata['url'] + url = self._create_csp_subscription_initial.metadata['url'] # type: ignore path_format_arguments = { 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_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') + 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, '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) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'ModernCspSubscriptionCreationParameters') + 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, 202]: - 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) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionCreationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } + deserialized = self._deserialize('SubscriptionCreationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def create_csp_subscription( - self, billing_account_name, customer_name, body, custom_headers=None, raw=False, polling=True, **operation_config): + return deserialized + _create_csp_subscription_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + def begin_create_csp_subscription( + self, + billing_account_name, # type: str + customer_name, # type: str + display_name, # type: str + sku_id, # type: str + reseller_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """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. + :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 + :param display_name: The friendly name of the subscription. + :type display_name: str + :param sku_id: 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 + :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 - :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` + :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 SubscriptionCreationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.SubscriptionCreationResult] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCreationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) 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 + display_name=display_name, + sku_id=sku_id, + reseller_id=reseller_id, + 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('SubscriptionCreationResult', 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_csp_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} # type: ignore + + def _create_alias_initial( + self, + alias_name, # type: str + properties=None, # type: Optional["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 = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_alias_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_alias_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def begin_create_alias( + self, + alias_name, # type: str + properties=None, # type: Optional["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_alias_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'int', - } - deserialized = self._deserialize('SubscriptionCreationResult', response) + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) 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) + 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) - create_csp_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'} + begin_create_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def get_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.get_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def delete_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.delete_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def list_alias( + 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 = "2019-10-01-preview" + + # Construct URL + url = self.list_alias.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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # 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 diff --git a/src/account/report.md b/src/account/report.md index dbffaf42067..d30c45f86ad 100644 --- a/src/account/report.md +++ b/src/account/report.md @@ -1,75 +1,123 @@ -# Azure CLI Module Creation Report - -### account operation list - -list a account operation. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription cancel - -cancel a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription create-csp-subscription - -create-csp-subscription a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|**--display-name**|string|The friendly name of the subscription.|/something/my_option|/something/myOption| -|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|/something/my_option|/something/myOption| -|--reseller-id**|string|Reseller ID, basically MPN Id.|/something/my_option|/something/myOption| -### account subscription create-subscription - -create-subscription a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|**--display-name**|string|The friendly name of the subscription.|/something/my_option|/something/myOption| -|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|/something/my_option|/something/myOption| -|--cost-center**|string|If set, the cost center will show up on the Azure usage and charges file.|/something/my_option|/something/myOption| -|--owner**|object|Active Directory Principal who’ll get owner access on the new subscription.|/something/my_option|/something/myOption| -|--management-group-id**|string|The identifier of the management group to which this subscription will be associated.|/something/my_option|/something/myOption| -### account subscription create-subscription-in-enrollment-account - -create-subscription-in-enrollment-account a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|The subscription creation parameters.|/something/my_option|/something/myOption| -|--display-name**|string|The display name of the subscription.|/something/my_option|/something/myOption| -|--management-group-id**|string|The Management Group Id.|/something/my_option|/something/myOption| -|--owners**|array|The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.|/something/my_option|/something/myOption| -|--offer-type**|choice|The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope.|/something/my_option|/something/myOption| -### account subscription enable - -enable a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -### account subscription rename - -rename a account subscription. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| -|**--body**|object|Subscription Name|/something/my_option|/something/myOption| -|--subscription-name**|string|New subscription name|/something/my_option|/something/myOption| -### account subscription-operation show - -show a account subscription-operation. - -|Option|Type|Description|Path (SDK)|Path (swagger)| -|------|----|-----------|----------|--------------| -|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| \ No newline at end of file +# Azure CLI Module Creation Report + +### account subscription cancel + +cancel a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--subscription-id**|string|Subscription Id.|subscription_id| +### account subscription create + +create a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--alias-name**|string|Alias Name|alias_name| +|**--properties**|object|Put alias request properties.|properties| +### account subscription create-csp-subscription + +create-csp-subscription a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--billing-account-name**|string|The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.|billing_account_name| +|**--customer-name**|string|The name of the customer.|customer_name| +|**--display-name**|string|The friendly name of the subscription.|display_name| +|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|sku_id| +|**--reseller-id**|string|Reseller ID, basically MPN Id.|reseller_id| +### account subscription create-subscription + +create-subscription a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--billing-account-name**|string|The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.|billing_account_name| +|**--billing-profile-name**|string|The name of the billing profile in the billing account for which you want to create the subscription.|billing_profile_name| +|**--invoice-section-name**|string|The name of the invoice section in the billing account for which you want to create the subscription.|invoice_section_name| +|**--display-name**|string|The friendly name of the subscription.|display_name| +|**--sku-id**|string|The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.|sku_id| +|**--cost-center**|string|If set, the cost center will show up on the Azure usage and charges file.|cost_center| +|**--management-group-id**|string|The identifier of the management group to which this subscription will be associated.|management_group_id| +|**--additional-parameters**|dictionary|Additional, untyped parameters to support custom subscription creation scenarios.|additional_parameters| +|**--owner-object-id**|string|Object id of the Principal|object_id| +### account subscription create-subscription-in-enrollment-account + +create-subscription-in-enrollment-account a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--enrollment-account-name**|string|The name of the enrollment account to which the subscription will be billed.|enrollment_account_name| +|**--display-name**|string|The display name of the subscription.|display_name| +|**--management-group-id**|string|The Management Group Id.|management_group_id| +|**--owners**|array|The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.|owners| +|**--offer-type**|choice|The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope.|offer_type| +|**--additional-parameters**|dictionary|Additional, untyped parameters to support custom subscription creation scenarios.|additional_parameters| +### account subscription delete + +delete a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--alias-name**|string|Alias Name|alias_name| +### account subscription enable + +enable a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--subscription-id**|string|Subscription Id.|subscription_id| +### account subscription get-alias + +get-alias a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--alias-name**|string|Alias Name|alias_name| +### account subscription list + +list a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +### account subscription list-alias + +list-alias a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +### account subscription list-location + +list-location a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id| +### account subscription rename + +rename a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--subscription-id**|string|Subscription Id.|subscription_id| +|**--subscription-name**|string|New subscription name|subscription_name| +### account subscription show + +show a account subscription. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--subscription-id**|string|The ID of the target subscription.|subscription_id| +### account subscription-operation show + +show a account subscription-operation. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--operation-id**|string|The operation ID, which can be found from the Location field in the generate recommendation response header.|operation_id| +### account tenant list + +list a account tenant. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| \ No newline at end of file diff --git a/src/account/setup.cfg b/src/account/setup.cfg index 3c6e79cf31d..2fdd96e5d39 100644 --- a/src/account/setup.cfg +++ b/src/account/setup.cfg @@ -1,2 +1 @@ -[bdist_wheel] -universal=1 +#setup.cfg \ No newline at end of file diff --git a/src/account/setup.py b/src/account/setup.py index 03591dc1fe5..83da68c0cc4 100644 --- a/src/account/setup.py +++ b/src/account/setup.py @@ -1,58 +1,57 @@ -#!/usr/bin/env python - -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - - -from codecs import open -from setuptools import setup, find_packages -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - logger.warn("Wheel is not available, disabling bdist_wheel hook") - -# TODO: Confirm this is the right version number you want and it matches your -# HISTORY.rst entry. -VERSION = '0.1.0' - -# The full list of classifiers is available at -# https://pypi.python.org/pypi?%3Aaction=list_classifiers -CLASSIFIERS = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'License :: OSI Approved :: MIT License', -] - -# TODO: Add any additional SDK dependencies here -DEPENDENCIES = [] - -with open('README.rst', 'r', encoding='utf-8') as f: - README = f.read() -with open('HISTORY.rst', 'r', encoding='utf-8') as f: - HISTORY = f.read() - -setup( - name='account', - version=VERSION, - description='Microsoft Azure Command-Line Tools SubscriptionClient Extension', - # TODO: Update author and email, if applicable - author='Microsoft Corporation', - author_email='azpycli@microsoft.com', - # TODO: consider pointing directly to your source code instead of the generic repo - url='https://github.com/Azure/azure-cli-extensions', - long_description=README + '\n\n' + HISTORY, - license='MIT', - classifiers=CLASSIFIERS, - packages=find_packages(), - install_requires=DEPENDENCIES, - package_data={'azext_account': ['azext_metadata.json']}, -) +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from .manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] +try: + from .manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='account', + version=VERSION, + description='Microsoft Azure Command-Line Tools SubscriptionClient Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/account', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_account': ['azext_metadata.json']}, +)