From 592a370e9d758d22dff20c942226b88716ca7afc Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Fri, 21 Aug 2020 08:01:13 +0000 Subject: [PATCH] Generated from b5cd6faa33042db894c8c9e9e3dd8bb69f0bb183 Update specification/subscription/resource-manager/readme.go.md Co-authored-by: Arcturus --- .../generated/_client_factory.py | 4 + src/account/azext_account/generated/_help.py | 93 +++--- .../azext_account/generated/_params.py | 29 +- .../azext_account/generated/commands.py | 15 +- src/account/azext_account/generated/custom.py | 47 +-- .../tests/latest/test_account_scenario.py | 67 ++-- .../subscription/_subscription_client.py | 5 + .../aio/_subscription_client_async.py | 5 + .../aio/operations_async/__init__.py | 2 + .../_alias_operations_async.py | 295 +++++++++++++++++ .../_subscription_operations_async.py | 260 +-------------- .../subscription/models/_models.py | 10 +- .../subscription/models/_models_py3.py | 10 +- .../subscription/operations/__init__.py | 2 + .../operations/_alias_operations.py | 304 ++++++++++++++++++ .../operations/_subscription_operations.py | 264 +-------------- src/account/report.md | 38 +-- 17 files changed, 806 insertions(+), 644 deletions(-) create mode 100644 src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py create mode 100644 src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py diff --git a/src/account/azext_account/generated/_client_factory.py b/src/account/azext_account/generated/_client_factory.py index bf0b4fc4fd1..356da5638cb 100644 --- a/src/account/azext_account/generated/_client_factory.py +++ b/src/account/azext_account/generated/_client_factory.py @@ -25,3 +25,7 @@ def cf_tenant(cli_ctx, *_): def cf_subscription(cli_ctx, *_): return cf_account(cli_ctx).subscription + + +def cf_alias(cli_ctx, *_): + return cf_account(cli_ctx).alias diff --git a/src/account/azext_account/generated/_help.py b/src/account/azext_account/generated/_help.py index 8f8749cae7f..8d7aec77498 100644 --- a/src/account/azext_account/generated/_help.py +++ b/src/account/azext_account/generated/_help.py @@ -64,37 +64,6 @@ 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=XX billing-scope=XX subscription-id=XX - - display-name: Required. The friendly name of the subscription. - workload: Required. The workload type of the subscription. It can be either Production or DevTest. - billing-scope: Required. Determines whether subscription is fieldLed, partnerLed or LegacyEA - subscription-id: This parameter can be used to create alias for existing subscription Id - examples: - - name: CreateAlias - text: |- - az account 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="Prod\ -uction" -""" - -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 @@ -113,30 +82,74 @@ az account subscription enable --subscription-id "7948bcee-488c-47ce-941c-38e20ede803d" """ -helps['account subscription get-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 alias'] = """ + type: group + short-summary: account alias +""" + +helps['account alias list'] = """ type: command short-summary: Get Alias Subscription. examples: - name: GetAlias text: |- - az account subscription get-alias --alias-name "aliasForNewSub" + az account alias list """ -helps['account subscription list-alias'] = """ +helps['account alias show'] = """ type: command short-summary: Get Alias Subscription. examples: - name: GetAlias text: |- - az account subscription list-alias + az account alias show --name "aliasForNewSub" """ -helps['account subscription rename'] = """ +helps['account alias create'] = """ type: command - short-summary: The operation to rename a subscription + short-summary: Create Alias Subscription. + parameters: + - name: --properties + short-summary: Put alias request properties. + long-summary: | + Usage: --properties display-name=XX workload=XX billing-scope=XX subscription-id=XX + + display-name: Required. The friendly name of the subscription. + workload: Required. The workload type of the subscription. It can be either Production or DevTest. + billing-scope: Required. Determines whether subscription is fieldLed, partnerLed or LegacyEA + subscription-id: This parameter can be used to create alias for existing subscription Id examples: - - name: renameSubscription + - name: CreateAlias text: |- - az account subscription rename --name "Test Sub" --subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad\ -" + az account alias create --name "aliasForNewSub" --properties billing-scope="/providers/Microsoft.Billing\ +/billingAccounts/e879cf0f-2b4d-5431-109a-f72fc9868693:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/P\ +E2Q-NOIT-BG7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" display-name="Contoso MCA subscription" workload="Production" +""" + +helps['account alias delete'] = """ + type: command + short-summary: Delete Alias. + examples: + - name: DeleteAlias + text: |- + az account alias delete --name "aliasForNewSub" +""" + +helps['account alias wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the account alias is met. + examples: + - name: Pause executing next line of CLI script until the account alias is successfully created. + text: |- + az account alias wait --name "aliasForNewSub" --created """ diff --git a/src/account/azext_account/generated/_params.py b/src/account/azext_account/generated/_params.py index f3f0e6ab1cc..25d78797924 100644 --- a/src/account/azext_account/generated/_params.py +++ b/src/account/azext_account/generated/_params.py @@ -27,25 +27,28 @@ def load_arguments(self, _): 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 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 alias list') as c: + pass + + with self.argument_context('account alias show') as c: + c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') + + with self.argument_context('account alias create') as c: + c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') + c.argument('properties', action=AddProperties, nargs='+', help='Put alias request properties.') + + with self.argument_context('account alias delete') as c: + c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') + + with self.argument_context('account alias wait') as c: + c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name') diff --git a/src/account/azext_account/generated/commands.py b/src/account/azext_account/generated/commands.py index de051c35ec3..f444cc0cb49 100644 --- a/src/account/azext_account/generated/commands.py +++ b/src/account/azext_account/generated/commands.py @@ -38,10 +38,17 @@ def load_command_table(self, _): 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('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_alias + account_alias = CliCommandType( + operations_tmpl='azext_account.vendored_sdks.subscription.operations._alias_operations#AliasOperations.{}', + client_factory=cf_alias) + with self.command_group('account alias', account_alias, client_factory=cf_alias, is_experimental=True) as g: + g.custom_command('list', 'account_alias_list') + g.custom_show_command('show', 'account_alias_show') + g.custom_command('create', 'account_alias_create', supports_no_wait=True) + g.custom_command('delete', 'account_alias_delete') + g.custom_wait_command('wait', 'account_alias_show') diff --git a/src/account/azext_account/generated/custom.py b/src/account/azext_account/generated/custom.py index 45b65144fea..303deb5a99c 100644 --- a/src/account/azext_account/generated/custom.py +++ b/src/account/azext_account/generated/custom.py @@ -9,6 +9,8 @@ # -------------------------------------------------------------------------- # pylint: disable=too-many-lines +from azure.cli.core.util import sdk_no_wait + def account_subscription_list(client): return client.list() @@ -28,18 +30,6 @@ 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) @@ -50,17 +40,32 @@ def account_subscription_enable(client, 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_alias_list(client): + return client.list() + + +def account_alias_show(client, + alias_name): + return client.get(alias_name=alias_name) + + +def account_alias_create(client, + alias_name, + properties, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create, + alias_name=alias_name, + properties=properties) + + +def account_alias_delete(client, + alias_name): + return client.delete(alias_name=alias_name) 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 0eb1322e46c..bcd761169b1 100644 --- a/src/account/azext_account/tests/latest/test_account_scenario.py +++ b/src/account/azext_account/tests/latest/test_account_scenario.py @@ -21,53 +21,51 @@ def setup(test): pass -# EXAMPLE: /Subscriptions/get/getSubscription +# EXAMPLE: /Alias/put/CreateAlias @try_manual -def step__subscriptions_get_getsubscription(test): - test.cmd('az account subscription show ' - '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', +def step__alias_put_createalias(test): + test.cmd('az account alias create ' + '--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="Production"', checks=[]) -# EXAMPLE: /Subscriptions/get/listLocations +# EXAMPLE: /Alias/get/GetAlias @try_manual -def step__subscriptions_get_listlocations(test): - test.cmd('az account subscription list-location ' - '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', +def step__alias_get_getalias(test): + test.cmd('az account alias list', checks=[]) -# EXAMPLE: /Subscriptions/get/listSubscriptions +# EXAMPLE: /Alias/get/GetAlias @try_manual -def step__subscriptions_get_listsubscriptions(test): - test.cmd('az account subscription list', +def step__alias_get_getalias(test): + test.cmd('az account alias list', checks=[]) -# EXAMPLE: /Subscription/put/CreateAlias +# EXAMPLE: /Subscriptions/get/getSubscription @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="Production"', +def step__subscriptions_get_getsubscription(test): + test.cmd('az account subscription show ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', checks=[]) -# EXAMPLE: /Subscription/get/GetAlias +# EXAMPLE: /Subscriptions/get/listLocations @try_manual -def step__subscription_get_getalias(test): - test.cmd('az account subscription get-alias ' - '--alias-name "aliasForNewSub"', +def step__subscriptions_get_listlocations(test): + test.cmd('az account subscription list-location ' + '--subscription-id "83aa47df-e3e9-49ff-877b-94304bf3d3ad"', checks=[]) -# EXAMPLE: /Subscription/get/GetAlias +# EXAMPLE: /Subscriptions/get/listSubscriptions @try_manual -def step__subscription_get_getalias(test): - test.cmd('az account subscription get-alias ' - '--alias-name "aliasForNewSub"', +def step__subscriptions_get_listsubscriptions(test): + test.cmd('az account subscription list', checks=[]) @@ -103,11 +101,11 @@ def step__tenants_get_listtenants(test): checks=[]) -# EXAMPLE: /Subscription/delete/DeleteAlias +# EXAMPLE: /Alias/delete/DeleteAlias @try_manual -def step__subscription_delete_deletealias(test): - test.cmd('az account subscription delete ' - '--alias-name "aliasForNewSub"', +def step__alias_delete_deletealias(test): + test.cmd('az account alias delete ' + '--name "{aliasForNewSub}"', checks=[]) @@ -119,17 +117,17 @@ def cleanup(test): @try_manual def call_scenario(test): setup(test) + step__alias_put_createalias(test) + step__alias_get_getalias(test) + step__alias_get_getalias(test) step__subscriptions_get_getsubscription(test) step__subscriptions_get_listlocations(test) step__subscriptions_get_listsubscriptions(test) - step__subscription_put_createalias(test) - step__subscription_get_getalias(test) - step__subscription_get_getalias(test) step__subscription_post_cancelsubscription(test) step__subscription_post_enablesubscription(test) step__subscription_post_renamesubscription(test) step__tenants_get_listtenants(test) - step__subscription_delete_deletealias(test) + step__alias_delete_deletealias(test) cleanup(test) @@ -140,6 +138,7 @@ def test_account(self): self.kwargs.update({ 'Test Sub': 'Test Sub', + 'aliasForNewSub': 'aliasForNewSub', }) call_scenario(self) 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 492641a278d..f07f6a8594a 100644 --- a/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py +++ b/src/account/azext_account/vendored_sdks/subscription/_subscription_client.py @@ -22,6 +22,7 @@ from .operations import TenantOperations from .operations import SubscriptionOperations from .operations import OperationOperations +from .operations import AliasOperations from . import models @@ -36,6 +37,8 @@ class SubscriptionClient(object): :vartype subscription: subscription_client.operations.SubscriptionOperations :ivar operation: OperationOperations operations :vartype operation: subscription_client.operations.OperationOperations + :ivar alias: AliasOperations operations + :vartype alias: subscription_client.operations.AliasOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param str base_url: Service URL @@ -66,6 +69,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.operation = OperationOperations( self._client, self._config, self._serialize, self._deserialize) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize) def close(self): # type: () -> None diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py index 9f9442f2935..a024387c173 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/_subscription_client_async.py @@ -20,6 +20,7 @@ from .operations_async import TenantOperations from .operations_async import SubscriptionOperations from .operations_async import OperationOperations +from .operations_async import AliasOperations from .. import models @@ -34,6 +35,8 @@ class SubscriptionClient(object): :vartype subscription: subscription_client.aio.operations_async.SubscriptionOperations :ivar operation: OperationOperations operations :vartype operation: subscription_client.aio.operations_async.OperationOperations + :ivar alias: AliasOperations operations + :vartype alias: subscription_client.aio.operations_async.AliasOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param str base_url: Service URL @@ -63,6 +66,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.operation = OperationOperations( self._client, self._config, self._serialize, self._deserialize) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize) async def close(self) -> None: await self._client.close() diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py index a860ac25678..13b77eb8918 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/__init__.py @@ -10,10 +10,12 @@ from ._tenant_operations_async import TenantOperations from ._subscription_operations_async import SubscriptionOperations from ._operation_operations_async import OperationOperations +from ._alias_operations_async import AliasOperations __all__ = [ 'SubscriptionOperations', 'TenantOperations', 'SubscriptionOperations', 'OperationOperations', + 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py new file mode 100644 index 00000000000..d5e817b84b3 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_alias_operations_async.py @@ -0,0 +1,295 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AliasOperations: + """AliasOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + alias_name: str, + properties: "models.PutAliasRequestProperties", + **kwargs + ) -> "models.PutAliasResponse": + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.PutAliasRequest(properties=properties) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def create( + self, + alias_name: str, + properties: "models.PutAliasRequestProperties", + **kwargs + ) -> "models.PutAliasResponse": + """Create Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def get( + self, + alias_name: str, + **kwargs + ) -> "models.PutAliasResponse": + """Get Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def delete( + self, + alias_name: str, + **kwargs + ) -> None: + """Delete Alias. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + async def list( + self, + **kwargs + ) -> "models.PutAliasListResult": + """Get Alias Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasListResult, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py index 4f8904e3f90..179d19f1336 100644 --- a/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py +++ b/src/account/azext_account/vendored_sdks/subscription/aio/operations_async/_subscription_operations_async.py @@ -5,15 +5,13 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +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.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 @@ -208,255 +206,13 @@ async def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - 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 = "2020-09-01" - 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 + return pipeline_response - 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 + return AsyncItemPaged( + get_next, extract_data ) - 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 = "2020-09-01" - - # 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 = "2020-09-01" - - # 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 = "2020-09-01" - - # 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 + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_models.py b/src/account/azext_account/vendored_sdks/subscription/models/_models.py index 9baf8df9a03..006dd95abc5 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models.py @@ -278,10 +278,16 @@ def __init__( class PutAliasRequest(msrest.serialization.Model): """The parameters required to create a new subscription. - :param properties: Put alias request properties. + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. :type properties: ~subscription_client.models.PutAliasRequestProperties """ + _validation = { + 'properties': {'required': True}, + } + _attribute_map = { 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } @@ -291,7 +297,7 @@ def __init__( **kwargs ): super(PutAliasRequest, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] class PutAliasRequestProperties(msrest.serialization.Model): diff --git a/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py b/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py index e3bf4aadd3b..9e8a6ed53e4 100644 --- a/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py +++ b/src/account/azext_account/vendored_sdks/subscription/models/_models_py3.py @@ -299,10 +299,16 @@ def __init__( class PutAliasRequest(msrest.serialization.Model): """The parameters required to create a new subscription. - :param properties: Put alias request properties. + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. :type properties: ~subscription_client.models.PutAliasRequestProperties """ + _validation = { + 'properties': {'required': True}, + } + _attribute_map = { 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } @@ -310,7 +316,7 @@ class PutAliasRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["PutAliasRequestProperties"] = None, + properties: "PutAliasRequestProperties", **kwargs ): super(PutAliasRequest, self).__init__(**kwargs) 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 e81db9810f5..f6227cb943f 100644 --- a/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py +++ b/src/account/azext_account/vendored_sdks/subscription/operations/__init__.py @@ -10,10 +10,12 @@ from ._tenant_operations import TenantOperations from ._subscription_operations import SubscriptionOperations from ._operation_operations import OperationOperations +from ._alias_operations import AliasOperations __all__ = [ 'SubscriptionOperations', 'TenantOperations', 'SubscriptionOperations', 'OperationOperations', + 'AliasOperations', ] diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py new file mode 100644 index 00000000000..e15d82be8c8 --- /dev/null +++ b/src/account/azext_account/vendored_sdks/subscription/operations/_alias_operations.py @@ -0,0 +1,304 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AliasOperations(object): + """AliasOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~subscription_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_initial( + self, + alias_name, # type: str + properties, # type: "models.PutAliasRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasResponse" + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.PutAliasRequest(properties=properties) + api_version = "2020-09-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_body, 'PutAliasRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def begin_create( + self, + alias_name, # type: str + properties, # type: "models.PutAliasRequestProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Create Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :param properties: Put alias request properties. + :type properties: ~subscription_client.models.PutAliasRequestProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either PutAliasResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.PutAliasResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._create_initial( + alias_name=alias_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def get( + self, + alias_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasResponse" + """Get Alias Subscription. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasResponse, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def delete( + self, + alias_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete Alias. + + :param alias_name: Alias Name. + :type alias_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.PutAliasListResult" + """Get Alias Subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PutAliasListResult, or the result of cls(response) + :rtype: ~subscription_client.models.PutAliasListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PutAliasListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore diff --git a/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py b/src/account/azext_account/vendored_sdks/subscription/operations/_subscription_operations.py index 63506dcdbe5..860f81f7178 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 @@ -11,15 +11,13 @@ from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -215,260 +213,12 @@ def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore +error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - 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 = "2020-09-01" - 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 + return pipeline_response - 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 + return ItemPaged( + get_next, extract_data ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PutAliasResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_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 = "2020-09-01" - - # 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 = "2020-09-01" - - # 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 = "2020-09-01" - - # 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 + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/account/report.md b/src/account/report.md index 915c13ed779..ff304b59601 100644 --- a/src/account/report.md +++ b/src/account/report.md @@ -1,50 +1,50 @@ # Azure CLI Module Creation Report -### account subscription cancel +### account alias create -cancel a account subscription. +create a account alias. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| -|**--subscription-id**|string|Subscription Id.|subscription_id| -### account subscription create +|**--alias-name**|string|Alias Name|alias_name| +|**--properties**|object|Put alias request properties.|properties| +### account alias delete -create a account subscription. +delete a account alias. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| |**--alias-name**|string|Alias Name|alias_name| -|**--properties**|object|Put alias request properties.|properties| -### account subscription delete +### account alias list -delete a account subscription. +list a account alias. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| -|**--alias-name**|string|Alias Name|alias_name| -### account subscription enable +### account alias show -enable a account subscription. +show a account alias. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| -|**--subscription-id**|string|Subscription Id.|subscription_id| -### account subscription get-alias +|**--alias-name**|string|Alias Name|alias_name| +### account subscription cancel -get-alias a account subscription. +cancel a account subscription. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| -|**--alias-name**|string|Alias Name|alias_name| -### account subscription list +|**--subscription-id**|string|Subscription Id.|subscription_id| +### account subscription enable -list a account subscription. +enable a account subscription. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------| -### account subscription list-alias +|**--subscription-id**|string|Subscription Id.|subscription_id| +### account subscription list -list-alias a account subscription. +list a account subscription. |Option|Type|Description|Path (SDK)|Path (swagger)| |------|----|-----------|----------|--------------|