From 748e1ff040c943697bc4c13aee95f61a8c652801 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Thu, 29 Oct 2020 14:17:10 +0800 Subject: [PATCH 01/11] Vendor subscription SDK --- .flake8 | 5 +- src/azure-cli-core/azure/cli/core/_profile.py | 38 +- .../azure/cli/core/adal_authentication.py | 10 + .../azure/cli/core/commands/client_factory.py | 12 +- .../azure/cli/core/tests/test_profile.py | 10 +- .../core/tests/test_profile_v2016_06_01.py | 10 +- .../vendored_sdks/subscriptions/__init__.py | 16 + .../subscriptions/_configuration.py | 60 ++ .../subscriptions/_operations_mixin.py | 61 ++ .../subscriptions/_subscription_client.py | 171 +++++ .../vendored_sdks/subscriptions/_version.py | 8 + .../vendored_sdks/subscriptions/models.py | 7 + .../core/vendored_sdks/subscriptions/py.typed | 1 + .../subscriptions/v2016_06_01/__init__.py | 16 + .../v2016_06_01/_configuration.py | 64 ++ .../subscriptions/v2016_06_01/_metadata.json | 62 ++ .../v2016_06_01/_subscription_client.py | 77 +++ .../subscriptions/v2016_06_01/aio/__init__.py | 10 + .../v2016_06_01/aio/_configuration.py | 60 ++ .../v2016_06_01/aio/_subscription_client.py | 71 ++ .../v2016_06_01/aio/operations/__init__.py | 19 + .../v2016_06_01/aio/operations/_operations.py | 104 +++ .../_subscription_client_operations.py | 83 +++ .../operations/_subscriptions_operations.py | 229 +++++++ .../aio/operations/_tenants_operations.py | 104 +++ .../v2016_06_01/models/__init__.py | 64 ++ .../v2016_06_01/models/_models.py | 438 ++++++++++++ .../v2016_06_01/models/_models_py3.py | 476 +++++++++++++ .../models/_subscription_client_enums.py | 52 ++ .../v2016_06_01/operations/__init__.py | 19 + .../v2016_06_01/operations/_operations.py | 109 +++ .../_subscription_client_operations.py | 88 +++ .../operations/_subscriptions_operations.py | 236 +++++++ .../operations/_tenants_operations.py | 109 +++ .../subscriptions/v2016_06_01/py.typed | 1 + .../subscriptions/v2018_06_01/__init__.py | 16 + .../v2018_06_01/_configuration.py | 64 ++ .../subscriptions/v2018_06_01/_metadata.json | 62 ++ .../v2018_06_01/_subscription_client.py | 77 +++ .../subscriptions/v2018_06_01/aio/__init__.py | 10 + .../v2018_06_01/aio/_configuration.py | 60 ++ .../v2018_06_01/aio/_subscription_client.py | 71 ++ .../v2018_06_01/aio/operations/__init__.py | 19 + .../v2018_06_01/aio/operations/_operations.py | 104 +++ .../_subscription_client_operations.py | 83 +++ .../operations/_subscriptions_operations.py | 229 +++++++ .../aio/operations/_tenants_operations.py | 104 +++ .../v2018_06_01/models/__init__.py | 64 ++ .../v2018_06_01/models/_models.py | 463 +++++++++++++ .../v2018_06_01/models/_models_py3.py | 501 ++++++++++++++ .../models/_subscription_client_enums.py | 52 ++ .../v2018_06_01/operations/__init__.py | 19 + .../v2018_06_01/operations/_operations.py | 109 +++ .../_subscription_client_operations.py | 88 +++ .../operations/_subscriptions_operations.py | 236 +++++++ .../operations/_tenants_operations.py | 109 +++ .../subscriptions/v2018_06_01/py.typed | 1 + .../subscriptions/v2019_06_01/__init__.py | 16 + .../v2019_06_01/_configuration.py | 64 ++ .../subscriptions/v2019_06_01/_metadata.json | 62 ++ .../v2019_06_01/_subscription_client.py | 77 +++ .../subscriptions/v2019_06_01/aio/__init__.py | 10 + .../v2019_06_01/aio/_configuration.py | 60 ++ .../v2019_06_01/aio/_subscription_client.py | 71 ++ .../v2019_06_01/aio/operations/__init__.py | 19 + .../v2019_06_01/aio/operations/_operations.py | 104 +++ .../_subscription_client_operations.py | 83 +++ .../operations/_subscriptions_operations.py | 229 +++++++ .../aio/operations/_tenants_operations.py | 104 +++ .../v2019_06_01/models/__init__.py | 69 ++ .../v2019_06_01/models/_models.py | 500 ++++++++++++++ .../v2019_06_01/models/_models_py3.py | 539 +++++++++++++++ .../models/_subscription_client_enums.py | 60 ++ .../v2019_06_01/operations/__init__.py | 19 + .../v2019_06_01/operations/_operations.py | 109 +++ .../_subscription_client_operations.py | 88 +++ .../operations/_subscriptions_operations.py | 236 +++++++ .../operations/_tenants_operations.py | 109 +++ .../subscriptions/v2019_06_01/py.typed | 1 + .../subscriptions/v2019_11_01/__init__.py | 16 + .../v2019_11_01/_configuration.py | 64 ++ .../subscriptions/v2019_11_01/_metadata.json | 62 ++ .../v2019_11_01/_subscription_client.py | 77 +++ .../subscriptions/v2019_11_01/aio/__init__.py | 10 + .../v2019_11_01/aio/_configuration.py | 60 ++ .../v2019_11_01/aio/_subscription_client.py | 71 ++ .../v2019_11_01/aio/operations/__init__.py | 19 + .../v2019_11_01/aio/operations/_operations.py | 104 +++ .../_subscription_client_operations.py | 83 +++ .../operations/_subscriptions_operations.py | 229 +++++++ .../aio/operations/_tenants_operations.py | 104 +++ .../v2019_11_01/models/__init__.py | 79 +++ .../v2019_11_01/models/_models.py | 595 ++++++++++++++++ .../v2019_11_01/models/_models_py3.py | 639 ++++++++++++++++++ .../models/_subscription_client_enums.py | 74 ++ .../v2019_11_01/operations/__init__.py | 19 + .../v2019_11_01/operations/_operations.py | 109 +++ .../_subscription_client_operations.py | 88 +++ .../operations/_subscriptions_operations.py | 236 +++++++ .../operations/_tenants_operations.py | 109 +++ .../subscriptions/v2019_11_01/py.typed | 1 + src/azure-cli-core/setup.py | 8 +- src/azure-cli/setup.py | 1 + 103 files changed, 10900 insertions(+), 27 deletions(-) create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_operations_mixin.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_version.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/models.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/py.typed create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_metadata.json create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models_py3.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_subscription_client_enums.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/py.typed create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_metadata.json create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models_py3.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_subscription_client_enums.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/__init__.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscription_client_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscriptions_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_tenants_operations.py create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/py.typed diff --git a/.flake8 b/.flake8 index 2f18f729601..2df4f07750f 100644 --- a/.flake8 +++ b/.flake8 @@ -11,11 +11,12 @@ ignore = per-file-ignores = # module level import not at top of file, elevate timer to measure import time src/azure-cli/azure/cli/__main__.py:E402 -exclude = +exclude = azure_bdist_wheel.py build tools scripts doc build_scripts - */grammar/ \ No newline at end of file + */grammar/ + vendored_sdks diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 79e08e5c91b..09df128bd4d 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -259,7 +259,7 @@ def _normalize_properties(self, user, subscriptions, is_service_principal, cert_ subscription_dict = { _SUBSCRIPTION_ID: s.id.rpartition('/')[2], _SUBSCRIPTION_NAME: display_name, - _STATE: s.state.value, + _STATE: s.state, _USER_ENTITY: { _USER_NAME: user, _USER_TYPE: _SERVICE_PRINCIPAL if is_service_principal else _USER @@ -813,14 +813,15 @@ def __init__(self, cli_ctx, auth_context_factory, adal_token_cache, arm_client_f def create_arm_client_factory(credentials): if arm_client_factory: return arm_client_factory(credentials) - from azure.cli.core.profiles._shared import get_client_class from azure.cli.core.profiles import ResourceType, get_api_version - from azure.cli.core.commands.client_factory import configure_common_settings - client_type = get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) + from azure.cli.core.commands.client_factory import _prepare_client_kwargs_track2 + + client_type = self._get_subscription_client_class(use_vendored_sdk=True) api_version = get_api_version(cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) + client_kwargs = _prepare_client_kwargs_track2(cli_ctx) + # We don't need to change credential_scopes as 'scopes' is ignored by BasicTokenCredential anyway client = client_type(credentials, api_version=api_version, - base_url=self.cli_ctx.cloud.endpoints.resource_manager) - configure_common_settings(cli_ctx, client) + base_url=self.cli_ctx.cloud.endpoints.resource_manager, **client_kwargs) return client self._arm_client_factory = create_arm_client_factory @@ -895,16 +896,17 @@ def _create_auth_context(self, tenant, use_token_cache=True): def _find_using_common_tenant(self, access_token, resource): import adal - from msrest.authentication import BasicTokenAuthentication + from azure.cli.core.adal_authentication import BasicTokenCredential all_subscriptions = [] empty_tenants = [] mfa_tenants = [] - token_credential = BasicTokenAuthentication({'access_token': access_token}) + token_credential = BasicTokenCredential(access_token) client = self._arm_client_factory(token_credential) tenants = client.tenants.list() for t in tenants: tenant_id = t.tenant_id + logger.debug("Finding subscriptions under tenant %s", tenant_id) # display_name is available since /tenants?api-version=2018-06-01, # not available in /tenants?api-version=2016-06-01 if not hasattr(t, 'display_name'): @@ -913,6 +915,7 @@ def _find_using_common_tenant(self, access_token, resource): t.display_name = t.additional_properties.get('displayName') temp_context = self._create_auth_context(tenant_id) try: + logger.debug("Acquiring a token with tenant=%s, resource=%s", tenant_id, resource) temp_credentials = temp_context.acquire_token(resource, self.user_id, _CLIENT_ID) except adal.AdalError as ex: # because user creds went through the 'common' tenant, the error here must be @@ -969,9 +972,9 @@ def _find_using_common_tenant(self, access_token, resource): return all_subscriptions def _find_using_specific_tenant(self, tenant, access_token): - from msrest.authentication import BasicTokenAuthentication + from azure.cli.core.adal_authentication import BasicTokenCredential - token_credential = BasicTokenAuthentication({'access_token': access_token}) + token_credential = BasicTokenCredential(access_token) client = self._arm_client_factory(token_credential) subscriptions = client.subscriptions.list() all_subscriptions = [] @@ -984,6 +987,21 @@ def _find_using_specific_tenant(self, tenant, access_token): self.tenants.append(tenant) return all_subscriptions + def _get_subscription_client_class(self, use_vendored_sdk=False): # pylint: disable=no-self-use + """Get the subscription client class. It can come from either the vendored SDK or public SDK, depending + on the design of architecture. + """ + if use_vendored_sdk: + # Use vendered subscription SDK to decouple from `resource` command module + from azure.cli.core.vendored_sdks.subscriptions import SubscriptionClient + client_type = SubscriptionClient + else: + from azure.cli.core.profiles._shared import get_client_class + from azure.cli.core.profiles import ResourceType + # Use the public SDK + client_type = get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) + return client_type + class CredsCache: '''Caches AAD tokena and service principal secrets, and persistence will diff --git a/src/azure-cli-core/azure/cli/core/adal_authentication.py b/src/azure-cli-core/azure/cli/core/adal_authentication.py index a4496b05d7a..4d7e8849b37 100644 --- a/src/azure-cli-core/azure/cli/core/adal_authentication.py +++ b/src/azure-cli-core/azure/cli/core/adal_authentication.py @@ -135,3 +135,13 @@ def set_token(self): def signed_session(self, session=None): logger.debug("MSIAuthenticationWrapper.signed_session invoked by Track 1 SDK") super().signed_session(session) + + +class BasicTokenCredential: + # pylint:disable=too-few-public-methods + """A Track 2 implementation of msrest.authentication.BasicTokenAuthentication.""" + def __init__(self, access_token): + self.access_token = access_token + + def get_token(self, *scopes, **kwargs): # pylint:disable=unused-argument + return AccessToken(self.access_token, int(time.time() + 3600)) diff --git a/src/azure-cli-core/azure/cli/core/commands/client_factory.py b/src/azure-cli-core/azure/cli/core/commands/client_factory.py index c8c4b5aa1bd..8361389c43a 100644 --- a/src/azure-cli-core/azure/cli/core/commands/client_factory.py +++ b/src/azure-cli-core/azure/cli/core/commands/client_factory.py @@ -110,12 +110,20 @@ def configure_common_settings(cli_ctx, client): client.config.generate_client_request_id = 'x-ms-client-request-id' not in cli_ctx.data['headers'] -def configure_common_settings_track2(cli_ctx): +def _prepare_client_kwargs_track2(cli_ctx): + """Prepare kwargs for Track 2 SDK client.""" client_kwargs = {} + # Change SSL verification behavior client_kwargs.update(_debug.change_ssl_cert_verification_track2()) + # Enable NetworkTraceLoggingPolicy which logs all headers (except Authorization) without being redacted client_kwargs['logging_enable'] = True + + # Disable ARMHttpLoggingPolicy which logs only allowed headers + from azure.core.pipeline.policies import SansIOHTTPPolicy + client_kwargs['http_logging_policy'] = SansIOHTTPPolicy() + client_kwargs['user_agent'] = get_az_user_agent() try: @@ -169,7 +177,7 @@ def _get_mgmt_service_client(cli_ctx, client_kwargs.update(kwargs) if is_track2(client_type): - client_kwargs.update(configure_common_settings_track2(cli_ctx)) + client_kwargs.update(_prepare_client_kwargs_track2(cli_ctx)) client_kwargs['credential_scopes'] = resource_to_scopes(resource) if subscription_bound: diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index b96af36a0ee..e5026de8416 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -314,7 +314,7 @@ def test_subscription_finder_constructor(self, get_api_mock): cli.cloud.endpoints.resource_manager = 'http://foo_arm' finder = SubscriptionFinder(cli, None, None, arm_client_factory=None) result = finder._arm_client_factory(mock.MagicMock()) - self.assertEqual(result.config.base_url, 'http://foo_arm') + self.assertEqual(result._client._base_url, 'http://foo_arm') @mock.patch('adal.AuthenticationContext', autospec=True) def test_get_auth_info_for_logged_in_service_principal(self, mock_auth_context): @@ -1072,7 +1072,7 @@ def find_from_raw_token(self, tenant, token): self.assertEqual(s['id'], self.id1.split('/')[-1]) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_system_assigned(self, mock_get_client_class, mock_get): class ClientStub: @@ -1110,7 +1110,7 @@ def __init__(self, *args, **kwargs): self.assertEqual(s['tenantId'], '54826b22-38d6-4fb2-bad9-b7b93a3e9c5a') @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_no_subscriptions(self, mock_get_client_class, mock_get): class ClientStub: @@ -1148,7 +1148,7 @@ def __init__(self, *args, **kwargs): self.assertEqual(s['tenantId'], self.test_msi_tenant) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_user_assigned_with_client_id(self, mock_get_client_class, mock_get): class ClientStub: @@ -1234,7 +1234,7 @@ def set_token(self): self.assertEqual(subscriptions[0]['user']['assignedIdentityInfo'], 'MSIObject-{}'.format(test_object_id)) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_user_assigned_with_res_id(self, mock_get_client_class, mock_get): class ClientStub: diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py index 22d795da86f..f36d43057b3 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py @@ -294,7 +294,7 @@ def test_subscription_finder_constructor(self, get_api_mock): cli.cloud.endpoints.resource_manager = 'http://foo_arm' finder = SubscriptionFinder(cli, None, None, arm_client_factory=None) result = finder._arm_client_factory(mock.MagicMock()) - self.assertEqual(result.config.base_url, 'http://foo_arm') + self.assertEqual(result._client._base_url, 'http://foo_arm') @mock.patch('adal.AuthenticationContext', autospec=True) def test_get_auth_info_for_logged_in_service_principal(self, mock_auth_context): @@ -934,7 +934,7 @@ def find_from_raw_token(self, tenant, token): self.assertEqual(s['id'], self.id1.split('/')[-1]) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_system_assigned(self, mock_get_client_class, mock_get): class ClientStub: @@ -972,7 +972,7 @@ def __init__(self, *args, **kwargs): self.assertEqual(s['tenantId'], '54826b22-38d6-4fb2-bad9-b7b93a3e9c5a') @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_no_subscriptions(self, mock_get_client_class, mock_get): class ClientStub: @@ -1010,7 +1010,7 @@ def __init__(self, *args, **kwargs): self.assertEqual(s['tenantId'], self.test_msi_tenant) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_user_assigned_with_client_id(self, mock_get_client_class, mock_get): class ClientStub: @@ -1096,7 +1096,7 @@ def set_token(self): self.assertEqual(subscriptions[0]['user']['assignedIdentityInfo'], 'MSIObject-{}'.format(test_object_id)) @mock.patch('requests.get', autospec=True) - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_find_subscriptions_in_vm_with_msi_user_assigned_with_res_id(self, mock_get_client_class, mock_get): class ClientStub: diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/__init__.py new file mode 100644 index 00000000000..a1d3eed7425 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/__init__.py @@ -0,0 +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. +# 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 import SubscriptionClient +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_configuration.py new file mode 100644 index 00000000000..5f293b616b5 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_configuration.py @@ -0,0 +1,60 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + + +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.TokenCredential + """ + + 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 = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_operations_mixin.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_operations_mixin.py new file mode 100644 index 00000000000..1bce276b8fc --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_operations_mixin.py @@ -0,0 +1,61 @@ +# 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 msrest import Serializer, Deserializer +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + +class SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["models.ResourceName"] + **kwargs # type: Any + ): + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('check_resource_name') + if api_version == '2016-06-01': + from .v2016_06_01.operations import SubscriptionClientOperationsMixin as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import SubscriptionClientOperationsMixin as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_01.operations import SubscriptionClientOperationsMixin as OperationClass + elif api_version == '2019-11-01': + from .v2019_11_01.operations import SubscriptionClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'check_resource_name'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.check_resource_name(resource_name_definition, **kwargs) diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_subscription_client.py new file mode 100644 index 00000000000..5ae49b182bb --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_subscription_client.py @@ -0,0 +1,171 @@ +# 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 azure.mgmt.core import ARMPipelineClient +from msrest import Serializer, Deserializer + +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin +from ._configuration import SubscriptionClientConfiguration +from ._operations_mixin import SubscriptionClientOperationsMixin +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class SubscriptionClient(SubscriptionClientOperationsMixin, MultiApiClientMixin, _SDKClient): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str api_version: API version to use if no profile is provided, or if + missing in profile. + :param str base_url: Service URL + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + """ + + DEFAULT_API_VERSION = '2019-11-01' + _PROFILE_TAG = "azure.mgmt.resource.SubscriptionClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential, # type: "TokenCredential" + api_version=None, + base_url=None, + profile=KnownProfiles.default, + **kwargs # type: Any + ): + 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) + super(SubscriptionClient, self).__init__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2016-06-01: :mod:`v2016_06_01.models` + * 2018-06-01: :mod:`v2018_06_01.models` + * 2019-06-01: :mod:`v2019_06_01.models` + * 2019-11-01: :mod:`v2019_11_01.models` + """ + if api_version == '2016-06-01': + from .v2016_06_01 import models + return models + elif api_version == '2018-06-01': + from .v2018_06_01 import models + return models + elif api_version == '2019-06-01': + from .v2019_06_01 import models + return models + elif api_version == '2019-11-01': + from .v2019_11_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def operations(self): + """Instance depends on the API version: + + * 2016-06-01: :class:`Operations` + * 2018-06-01: :class:`Operations` + * 2019-06-01: :class:`Operations` + * 2019-11-01: :class:`Operations` + """ + api_version = self._get_api_version('operations') + if api_version == '2016-06-01': + from .v2016_06_01.operations import Operations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import Operations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_01.operations import Operations as OperationClass + elif api_version == '2019-11-01': + from .v2019_11_01.operations import Operations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def subscriptions(self): + """Instance depends on the API version: + + * 2016-06-01: :class:`SubscriptionsOperations` + * 2018-06-01: :class:`SubscriptionsOperations` + * 2019-06-01: :class:`SubscriptionsOperations` + * 2019-11-01: :class:`SubscriptionsOperations` + """ + api_version = self._get_api_version('subscriptions') + if api_version == '2016-06-01': + from .v2016_06_01.operations import SubscriptionsOperations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import SubscriptionsOperations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_01.operations import SubscriptionsOperations as OperationClass + elif api_version == '2019-11-01': + from .v2019_11_01.operations import SubscriptionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'subscriptions'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def tenants(self): + """Instance depends on the API version: + + * 2016-06-01: :class:`TenantsOperations` + * 2018-06-01: :class:`TenantsOperations` + * 2019-06-01: :class:`TenantsOperations` + * 2019-11-01: :class:`TenantsOperations` + """ + api_version = self._get_api_version('tenants') + if api_version == '2016-06-01': + from .v2016_06_01.operations import TenantsOperations as OperationClass + elif api_version == '2018-06-01': + from .v2018_06_01.operations import TenantsOperations as OperationClass + elif api_version == '2019-06-01': + from .v2019_06_01.operations import TenantsOperations as OperationClass + elif api_version == '2019-11-01': + from .v2019_11_01.operations import TenantsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'tenants'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + def close(self): + self._client.close() + def __enter__(self): + self._client.__enter__() + return self + def __exit__(self, *exc_details): + self._client.__exit__(*exc_details) diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_version.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_version.py new file mode 100644 index 00000000000..a30a458f8b5 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/_version.py @@ -0,0 +1,8 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/models.py new file mode 100644 index 00000000000..28ba9b61c72 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/models.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- +from .v2019_11_01.models import * diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/__init__.py new file mode 100644 index 00000000000..a1d3eed7425 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/__init__.py @@ -0,0 +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. +# 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 import SubscriptionClient +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_configuration.py new file mode 100644 index 00000000000..362180e421d --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_configuration.py @@ -0,0 +1,64 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +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.TokenCredential + """ + + 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.api_version = "2016-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_metadata.json new file mode 100644 index 00000000000..82aa0c625bb --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2016-06-01", + "total_api_version_list": ["2016-06-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + "check_resource_name" : { + "sync": { + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_name_definition" + } + }, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" +} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_subscription_client.py new file mode 100644 index 00000000000..4ea5a929ebe --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/_subscription_client.py @@ -0,0 +1,77 @@ +# 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 + +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 Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from . import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + 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._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py new file mode 100644 index 00000000000..25a76f1a699 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/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 import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py new file mode 100644 index 00000000000..92539d2f67d --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py @@ -0,0 +1,60 @@ +# 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 +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +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.api_version = "2016-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py new file mode 100644 index 00000000000..6dd814071c6 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.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. +# -------------------------------------------------------------------------- + +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 import SubscriptionClientConfiguration +from .operations import Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from .. import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py new file mode 100644 index 00000000000..79a97b3cff3 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..d9614d6ec24 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionClientOperationsMixin: + + async def check_resource_name( + self, + resource_name_definition: Optional["models.ResourceName"] = None, + **kwargs + ) -> "models.CheckResourceNameResult": + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..3afeddc430b --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py @@ -0,0 +1,229 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py new file mode 100644 index 00000000000..ee13e72c0e7 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/__init__.py new file mode 100644 index 00000000000..4d3bb8b7d25 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/__init__.py @@ -0,0 +1,64 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CheckResourceNameResult + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse + from ._models_py3 import Location + from ._models_py3 import LocationListResult + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ResourceName + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult +except (SyntaxError, ImportError): + from ._models import CheckResourceNameResult # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ResourceName # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # 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 ( + ResourceNameStatus, + SpendingLimit, + SubscriptionState, +) + +__all__ = [ + 'CheckResourceNameResult', + 'ErrorDefinition', + 'ErrorResponse', + 'Location', + 'LocationListResult', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ResourceName', + 'Subscription', + 'SubscriptionListResult', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'ResourceNameStatus', + 'SpendingLimit', + 'SubscriptionState', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models.py new file mode 100644 index 00000000000..011eca63f95 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models.py @@ -0,0 +1,438 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.status = kwargs.get('status', None) + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = kwargs.get('message', None) + self.code = kwargs.get('code', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, 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 LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.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 Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + 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) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs['type'] + + +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 ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2016_06_01.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 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[~azure.mgmt.resource.subscriptions.v2016_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2016_06_01.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[~azure.mgmt.resource.subscriptions.v2016_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models_py3.py new file mode 100644 index 00000000000..b6e20cf666d --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_models_py3.py @@ -0,0 +1,476 @@ +# 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 List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._subscription_client_enums import * + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + status: Optional[Union[str, "ResourceNameStatus"]] = None, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = name + self.type = type + self.status = status + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + code: Optional[str] = None, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = message + self.code = code + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, 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 + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.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 Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + 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(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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 ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: str, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = name + self.type = type + + +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 ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies + :param authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :type authorization_source: str + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + } + + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + + +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2016_06_01.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[~azure.mgmt.resource.subscriptions.v2016_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_subscription_client_enums.py new file mode 100644 index 00000000000..cec9f01471e --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/models/_subscription_client_enums.py @@ -0,0 +1,52 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Is the resource name Allowed or Reserved + """ + + ALLOWED = "Allowed" + RESERVED = "Reserved" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription spending limit. + """ + + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_operations.py new file mode 100644 index 00000000000..5ecdee7b607 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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.OperationListResult"] + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..48bf0371300 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscription_client_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.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 SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["models.ResourceName"] + **kwargs # type: Any + ): + # type: (...) -> "models.CheckResourceNameResult" + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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]: + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..97e7851ece6 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_subscriptions_operations.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations(object): + """SubscriptionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_tenants_operations.py new file mode 100644 index 00000000000..3a4ec17c755 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/operations/_tenants_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations(object): + """TenantsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py new file mode 100644 index 00000000000..a1d3eed7425 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py @@ -0,0 +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. +# 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 import SubscriptionClient +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py new file mode 100644 index 00000000000..2fe47dd5c19 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py @@ -0,0 +1,64 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +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.TokenCredential + """ + + 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.api_version = "2018-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json new file mode 100644 index 00000000000..a9b7fbf364b --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2018-06-01", + "total_api_version_list": ["2018-06-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + "check_resource_name" : { + "sync": { + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_name_definition" + } + }, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" +} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py new file mode 100644 index 00000000000..8720f19331a --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py @@ -0,0 +1,77 @@ +# 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 + +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 Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from . import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + 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._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py new file mode 100644 index 00000000000..25a76f1a699 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/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 import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py new file mode 100644 index 00000000000..387cd5c7a70 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py @@ -0,0 +1,60 @@ +# 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 +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +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.api_version = "2018-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py new file mode 100644 index 00000000000..661f9572726 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.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. +# -------------------------------------------------------------------------- + +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 import SubscriptionClientConfiguration +from .operations import Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from .. import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py new file mode 100644 index 00000000000..871caa4e83f --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..7ef0546f009 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionClientOperationsMixin: + + async def check_resource_name( + self, + resource_name_definition: Optional["models.ResourceName"] = None, + **kwargs + ) -> "models.CheckResourceNameResult": + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..11a3c2bb503 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py @@ -0,0 +1,229 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py new file mode 100644 index 00000000000..32c40c32f1e --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py new file mode 100644 index 00000000000..4d3bb8b7d25 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py @@ -0,0 +1,64 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CheckResourceNameResult + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse + from ._models_py3 import Location + from ._models_py3 import LocationListResult + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ResourceName + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult +except (SyntaxError, ImportError): + from ._models import CheckResourceNameResult # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ResourceName # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # 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 ( + ResourceNameStatus, + SpendingLimit, + SubscriptionState, +) + +__all__ = [ + 'CheckResourceNameResult', + 'ErrorDefinition', + 'ErrorResponse', + 'Location', + 'LocationListResult', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ResourceName', + 'Subscription', + 'SubscriptionListResult', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'ResourceNameStatus', + 'SpendingLimit', + 'SubscriptionState', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py new file mode 100644 index 00000000000..e7f7b644f9b --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py @@ -0,0 +1,463 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.status = kwargs.get('status', None) + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = kwargs.get('message', None) + self.code = kwargs.get('code', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, 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 LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + 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) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs['type'] + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2018_06_01.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}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', '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.tenant_id = None + self.state = None + self.subscription_policies = kwargs.get('subscription_policies', None) + self.authorization_source = kwargs.get('authorization_source', None) + + +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[~azure.mgmt.resource.subscriptions.v2018_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2018_06_01.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 + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2018_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py new file mode 100644 index 00000000000..c0e1457f1a7 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py @@ -0,0 +1,501 @@ +# 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 List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._subscription_client_enums import * + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + status: Optional[Union[str, "ResourceNameStatus"]] = None, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = name + self.type = type + self.status = status + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + code: Optional[str] = None, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = message + self.code = code + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, 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 + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + 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(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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 ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: str, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = name + self.type = type + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2018_06_01.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}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', '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.tenant_id = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + + +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: An array of subscriptions. + :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2018_06_01.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 + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2018_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py new file mode 100644 index 00000000000..cec9f01471e --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py @@ -0,0 +1,52 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Is the resource name Allowed or Reserved + """ + + ALLOWED = "Allowed" + RESERVED = "Reserved" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription spending limit. + """ + + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py new file mode 100644 index 00000000000..a654caa6c06 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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.OperationListResult"] + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..f43b9a9a880 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.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 SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["models.ResourceName"] + **kwargs # type: Any + ): + # type: (...) -> "models.CheckResourceNameResult" + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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]: + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..3062a750e69 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations(object): + """SubscriptionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py new file mode 100644 index 00000000000..ba68b8c7e4f --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations(object): + """TenantsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py new file mode 100644 index 00000000000..a1d3eed7425 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py @@ -0,0 +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. +# 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 import SubscriptionClient +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py new file mode 100644 index 00000000000..2be8dc9ddd2 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py @@ -0,0 +1,64 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +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.TokenCredential + """ + + 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.api_version = "2019-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json new file mode 100644 index 00000000000..eb91cd1a145 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2019-06-01", + "total_api_version_list": ["2019-06-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + "check_resource_name" : { + "sync": { + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_name_definition" + } + }, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" +} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py new file mode 100644 index 00000000000..5d72fa82597 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py @@ -0,0 +1,77 @@ +# 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 + +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 Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from . import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + 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._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py new file mode 100644 index 00000000000..25a76f1a699 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/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 import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py new file mode 100644 index 00000000000..9c42a86df36 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py @@ -0,0 +1,60 @@ +# 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 +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +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.api_version = "2019-06-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py new file mode 100644 index 00000000000..771cb77eac3 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.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. +# -------------------------------------------------------------------------- + +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 import SubscriptionClientConfiguration +from .operations import Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from .. import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py new file mode 100644 index 00000000000..c2bd4e487d4 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..b781a886fde --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionClientOperationsMixin: + + async def check_resource_name( + self, + resource_name_definition: Optional["models.ResourceName"] = None, + **kwargs + ) -> "models.CheckResourceNameResult": + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..3c9d13f4f06 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py @@ -0,0 +1,229 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py new file mode 100644 index 00000000000..1cf2211d3bd --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py new file mode 100644 index 00000000000..7dccb979f7c --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py @@ -0,0 +1,69 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CheckResourceNameResult + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse + from ._models_py3 import Location + from ._models_py3 import LocationListResult + from ._models_py3 import ManagedByTenant + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ResourceName + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult +except (SyntaxError, ImportError): + from ._models import CheckResourceNameResult # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import ManagedByTenant # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ResourceName # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # 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 ( + ResourceNameStatus, + SpendingLimit, + SubscriptionState, + TenantCategory, +) + +__all__ = [ + 'CheckResourceNameResult', + 'ErrorDefinition', + 'ErrorResponse', + 'Location', + 'LocationListResult', + 'ManagedByTenant', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ResourceName', + 'Subscription', + 'SubscriptionListResult', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'ResourceNameStatus', + 'SpendingLimit', + 'SubscriptionState', + 'TenantCategory', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py new file mode 100644 index 00000000000..098139fbac4 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py @@ -0,0 +1,500 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.status = kwargs.get('status', None) + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = kwargs.get('message', None) + self.code = kwargs.get('code', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, 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 LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.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 ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = None + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + 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) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs['type'] + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_06_01.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 + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + } + + def __init__( + self, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = kwargs.get('subscription_policies', None) + self.authorization_source = kwargs.get('authorization_source', None) + self.managed_by_tenants = kwargs.get('managed_by_tenants', None) + + +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[~azure.mgmt.resource.subscriptions.v2019_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2019_06_01.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 + :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py new file mode 100644 index 00000000000..9187caff6e2 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py @@ -0,0 +1,539 @@ +# 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 List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._subscription_client_enums import * + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + status: Optional[Union[str, "ResourceNameStatus"]] = None, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = name + self.type = type + self.status = status + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + code: Optional[str] = None, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = message + self.code = code + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, 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 + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.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 ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = None + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + 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(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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 ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: str, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = name + self.type = type + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_06_01.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 + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + } + + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + self.managed_by_tenants = managed_by_tenants + + +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[~azure.mgmt.resource.subscriptions.v2019_06_01.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 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 + ~azure.mgmt.resource.subscriptions.v2019_06_01.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 + :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py new file mode 100644 index 00000000000..22d3c785556 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py @@ -0,0 +1,60 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Is the resource name Allowed or Reserved + """ + + ALLOWED = "Allowed" + RESERVED = "Reserved" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription spending limit. + """ + + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" + +class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The tenant category. + """ + + HOME = "Home" + PROJECTED_BY = "ProjectedBy" + MANAGED_BY = "ManagedBy" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py new file mode 100644 index 00000000000..65378646244 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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.OperationListResult"] + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..108314fb8f8 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.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 SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["models.ResourceName"] + **kwargs # type: Any + ): + # type: (...) -> "models.CheckResourceNameResult" + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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]: + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..964156397dc --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations(object): + """SubscriptionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py new file mode 100644 index 00000000000..fe5804617e2 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations(object): + """TenantsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/__init__.py new file mode 100644 index 00000000000..a1d3eed7425 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/__init__.py @@ -0,0 +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. +# 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 import SubscriptionClient +__all__ = ['SubscriptionClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_configuration.py new file mode 100644 index 00000000000..fe418b780a3 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_configuration.py @@ -0,0 +1,64 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +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.TokenCredential + """ + + 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.api_version = "2019-11-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_metadata.json new file mode 100644 index 00000000000..f156f87e352 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2019-11-01", + "total_api_version_list": ["2019-11-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + "check_resource_name" : { + "sync": { + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_name_definition" + } + }, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" +} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_subscription_client.py new file mode 100644 index 00000000000..c5a657890a8 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/_subscription_client.py @@ -0,0 +1,77 @@ +# 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 + +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 Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from . import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + 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._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py new file mode 100644 index 00000000000..25a76f1a699 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/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 import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py new file mode 100644 index 00000000000..e1994b337ed --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py @@ -0,0 +1,60 @@ +# 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 +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +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.api_version = "2019-11-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py new file mode 100644 index 00000000000..aa1e8a2bdfe --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.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. +# -------------------------------------------------------------------------- + +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 import SubscriptionClientConfiguration +from .operations import Operations +from .operations import SubscriptionsOperations +from .operations import TenantsOperations +from .operations import SubscriptionClientOperationsMixin +from .. import models + + +class SubscriptionClient(SubscriptionClientOperationsMixin): + """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.TenantsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + 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._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations( + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py new file mode 100644 index 00000000000..d2311754ea1 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..679c2ab2fd5 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionClientOperationsMixin: + + async def check_resource_name( + self, + resource_name_definition: Optional["models.ResourceName"] = None, + **kwargs + ) -> "models.CheckResourceNameResult": + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..95883e6835d --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py @@ -0,0 +1,229 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py new file mode 100644 index 00000000000..2007d467330 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py @@ -0,0 +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. +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/__init__.py new file mode 100644 index 00000000000..961846b3a32 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/__init__.py @@ -0,0 +1,79 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CheckResourceNameResult + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse + from ._models_py3 import Location + from ._models_py3 import LocationListResult + from ._models_py3 import LocationMetadata + from ._models_py3 import ManagedByTenant + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import PairedRegion + from ._models_py3 import ResourceName + from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult + from ._models_py3 import SubscriptionPolicies + from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult +except (SyntaxError, ImportError): + from ._models import CheckResourceNameResult # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import LocationMetadata # type: ignore + from ._models import ManagedByTenant # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import PairedRegion # type: ignore + from ._models import ResourceName # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # 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 ( + RegionCategory, + RegionType, + ResourceNameStatus, + SpendingLimit, + SubscriptionState, + TenantCategory, +) + +__all__ = [ + 'CheckResourceNameResult', + 'ErrorDefinition', + 'ErrorResponse', + 'Location', + 'LocationListResult', + 'LocationMetadata', + 'ManagedByTenant', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'PairedRegion', + 'ResourceName', + 'Subscription', + 'SubscriptionListResult', + 'SubscriptionPolicies', + 'TenantIdDescription', + 'TenantListResult', + 'RegionCategory', + 'RegionType', + 'ResourceNameStatus', + 'SpendingLimit', + 'SubscriptionState', + 'TenantCategory', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models.py new file mode 100644 index 00000000000..cd7ffe36059 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models.py @@ -0,0 +1,595 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.status = kwargs.get('status', None) + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = kwargs.get('message', None) + self.code = kwargs.get('code', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, 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 regional_display_name: The display name of the location and its region. + :vartype regional_display_name: str + :param metadata: Metadata of the location, such as lat/long, paired region, and others. + :type metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + 'regional_display_name': {'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'}, + 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.display_name = None + self.regional_display_name = None + self.metadata = kwargs.get('metadata', None) + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.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 LocationMetadata(msrest.serialization.Model): + """Location metadata information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Other". + :vartype region_category: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionCategory + :ivar geography_group: The geography group of the location. + :vartype geography_group: str + :ivar longitude: The longitude of the location. + :vartype longitude: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar physical_location: The physical location of the Azure location. + :vartype physical_location: str + :param paired_region: The regions paired to this region. + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + """ + + _validation = { + 'region_type': {'readonly': True}, + 'region_category': {'readonly': True}, + 'geography_group': {'readonly': True}, + 'longitude': {'readonly': True}, + 'latitude': {'readonly': True}, + 'physical_location': {'readonly': True}, + } + + _attribute_map = { + 'region_type': {'key': 'regionType', 'type': 'str'}, + 'region_category': {'key': 'regionCategory', 'type': 'str'}, + 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, + 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationMetadata, self).__init__(**kwargs) + self.region_type = None + self.region_category = None + self.geography_group = None + self.longitude = None + self.latitude = None + self.physical_location = None + self.paired_region = kwargs.get('paired_region', None) + + +class ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = None + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + 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) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PairedRegion(msrest.serialization.Model): + """Information regarding paired region. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the paired region. + :vartype name: str + :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 + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PairedRegion, self).__init__(**kwargs) + self.name = None + self.id = None + self.subscription_id = None + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = kwargs['name'] + self.type = kwargs['type'] + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_11_01.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 + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] + :param tags: A set of tags. The tags attached to the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = kwargs.get('subscription_policies', None) + self.authorization_source = kwargs.get('authorization_source', None) + self.managed_by_tenants = kwargs.get('managed_by_tenants', None) + self.tags = kwargs.get('tags', None) + + +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[~azure.mgmt.resource.subscriptions.v2019_11_01.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 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 + ~azure.mgmt.resource.subscriptions.v2019_11_01.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 + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_11_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models_py3.py new file mode 100644 index 00000000000..b1564c2e400 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_models_py3.py @@ -0,0 +1,639 @@ +# 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 Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._subscription_client_enums import * + + +class CheckResourceNameResult(msrest.serialization.Model): + """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + + :param name: Name of Resource. + :type name: str + :param type: Type of Resource. + :type type: str + :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :type status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + status: Optional[Union[str, "ResourceNameStatus"]] = None, + **kwargs + ): + super(CheckResourceNameResult, self).__init__(**kwargs) + self.name = name + self.type = type + self.status = status + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why resource name is invalid. + + :param message: Description of the error. + :type message: str + :param code: Code of the error. + :type code: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + code: Optional[str] = None, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.message = message + self.code = code + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, 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 regional_display_name: The display name of the location and its region. + :vartype regional_display_name: str + :param metadata: Metadata of the location, such as lat/long, paired region, and others. + :type metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'readonly': True}, + 'regional_display_name': {'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'}, + 'regional_display_name': {'key': 'regionalDisplayName', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, + } + + def __init__( + self, + *, + metadata: Optional["LocationMetadata"] = None, + **kwargs + ): + super(Location, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.name = None + self.display_name = None + self.regional_display_name = None + self.metadata = metadata + + +class LocationListResult(msrest.serialization.Model): + """Location list operation response. + + :param value: An array of locations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.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 LocationMetadata(msrest.serialization.Model): + """Location metadata information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Other". + :vartype region_category: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionCategory + :ivar geography_group: The geography group of the location. + :vartype geography_group: str + :ivar longitude: The longitude of the location. + :vartype longitude: str + :ivar latitude: The latitude of the location. + :vartype latitude: str + :ivar physical_location: The physical location of the Azure location. + :vartype physical_location: str + :param paired_region: The regions paired to this region. + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + """ + + _validation = { + 'region_type': {'readonly': True}, + 'region_category': {'readonly': True}, + 'geography_group': {'readonly': True}, + 'longitude': {'readonly': True}, + 'latitude': {'readonly': True}, + 'physical_location': {'readonly': True}, + } + + _attribute_map = { + 'region_type': {'key': 'regionType', 'type': 'str'}, + 'region_category': {'key': 'regionCategory', 'type': 'str'}, + 'geography_group': {'key': 'geographyGroup', 'type': 'str'}, + 'longitude': {'key': 'longitude', 'type': 'str'}, + 'latitude': {'key': 'latitude', 'type': 'str'}, + 'physical_location': {'key': 'physicalLocation', 'type': 'str'}, + 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, + } + + def __init__( + self, + *, + paired_region: Optional[List["PairedRegion"]] = None, + **kwargs + ): + super(LocationMetadata, self).__init__(**kwargs) + self.region_type = None + self.region_category = None + self.geography_group = None + self.longitude = None + self.latitude = None + self.physical_location = None + self.paired_region = paired_region + + +class ManagedByTenant(msrest.serialization.Model): + """Information about a tenant managing the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. + :vartype tenant_id: str + """ + + _validation = { + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ManagedByTenant, self).__init__(**kwargs) + self.tenant_id = None + + +class Operation(msrest.serialization.Model): + """Microsoft.Resources operation. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + 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(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider: Microsoft.Resources. + :type provider: str + :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 + :param description: Description of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. + + :param value: List of Microsoft.Resources operations. + :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + 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 PairedRegion(msrest.serialization.Model): + """Information regarding paired region. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the paired region. + :vartype name: str + :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 + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PairedRegion, self).__init__(**kwargs) + self.name = None + self.id = None + self.subscription_id = None + + +class ResourceName(msrest.serialization.Model): + """Name and Type of the Resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Name of the resource. + :type name: str + :param type: Required. The type of the resource. + :type type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + type: str, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.name = name + self.type = type + + +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 tenant_id: The subscription tenant ID. + :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionState + :param subscription_policies: The subscription policies. + :type subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_11_01.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 + :param managed_by_tenants: An array containing the tenants managing the subscription. + :type managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] + :param tags: A set of tags. The tags attached to the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, + 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, + 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Subscription, self).__init__(**kwargs) + self.id = None + self.subscription_id = None + self.display_name = None + self.tenant_id = None + self.state = None + self.subscription_policies = subscription_policies + self.authorization_source = authorization_source + self.managed_by_tenants = managed_by_tenants + self.tags = tags + + +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[~azure.mgmt.resource.subscriptions.v2019_11_01.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 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 + ~azure.mgmt.resource.subscriptions.v2019_11_01.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 + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". + :vartype tenant_category: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantCategory + :ivar country: Country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TenantIdDescription, self).__init__(**kwargs) + self.id = None + self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_11_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_subscription_client_enums.py new file mode 100644 index 00000000000..94c6f35f02b --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/models/_subscription_client_enums.py @@ -0,0 +1,74 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class RegionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The category of the region. + """ + + RECOMMENDED = "Recommended" + OTHER = "Other" + +class RegionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the region. + """ + + PHYSICAL = "Physical" + LOGICAL = "Logical" + +class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Is the resource name Allowed or Reserved + """ + + ALLOWED = "Allowed" + RESERVED = "Reserved" + +class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription spending limit. + """ + + ON = "On" + OFF = "Off" + CURRENT_PERIOD_OFF = "CurrentPeriodOff" + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ + + ENABLED = "Enabled" + WARNED = "Warned" + PAST_DUE = "PastDue" + DISABLED = "Disabled" + DELETED = "Deleted" + +class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Category of the tenant. + """ + + HOME = "Home" + PROJECTED_BY = "ProjectedBy" + MANAGED_BY = "ManagedBy" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/__init__.py new file mode 100644 index 00000000000..228a89205db --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._subscriptions_operations import SubscriptionsOperations +from ._tenants_operations import TenantsOperations +from ._subscription_client_operations import SubscriptionClientOperationsMixin + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', + 'SubscriptionClientOperationsMixin', +] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_operations.py new file mode 100644 index 00000000000..3cbc9139d46 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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.OperationListResult"] + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscription_client_operations.py new file mode 100644 index 00000000000..bef87f0e352 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscription_client_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.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 SubscriptionClientOperationsMixin(object): + + def check_resource_name( + self, + resource_name_definition=None, # type: Optional["models.ResourceName"] + **kwargs # type: Any + ): + # type: (...) -> "models.CheckResourceNameResult" + """Checks resource name validity. + + A resource name is valid if it is not a reserved word, does not contains a reserved word and + does not start with a reserved word. + + :param resource_name_definition: Resource object with values for resource name and resource + type. + :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckResourceNameResult, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if resource_name_definition is not None: + body_content = self._serialize.body(resource_name_definition, 'ResourceName') + else: + body_content = None + 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]: + 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('CheckResourceNameResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscriptions_operations.py new file mode 100644 index 00000000000..28409e8836c --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_subscriptions_operations.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations(object): + """SubscriptionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """Gets all available geo-locations. + + This operation provides all the locations that are available for resource providers; however, + each resource provider may support a subset of this list. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_locations.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + def get( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription, or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] + """Gets all subscriptions for a tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_tenants_operations.py new file mode 100644 index 00000000000..70e257db0f1 --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/operations/_tenants_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations(object): + """TenantsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index 7912fb2e318..85794f56f71 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -52,7 +52,6 @@ 'knack==0.7.2', 'msal~=1.0.0', 'msal-extensions~=0.1.3', - 'msrest>=0.4.4', 'msrestazure>=0.6.3', 'paramiko>=2.0.8,<3.0.0', 'PyJWT', @@ -60,8 +59,11 @@ 'requests~=2.22', 'six~=1.12', 'pkginfo>=1.5.0.1', - 'azure-mgmt-resource==10.2.0', - 'azure-mgmt-core==1.2.0' + # Dependencies of the vendored subscription SDK + # https://github.com/Azure/azure-sdk-for-python/blob/ab12b048ddf676fe0ccec16b2167117f0609700d/sdk/resources/azure-mgmt-resource/setup.py#L82-L86 + 'msrest>=0.5.0', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', ] TESTS_REQUIRE = [ diff --git a/src/azure-cli/setup.py b/src/azure-cli/setup.py index 3440d231a08..7d9a963ea99 100644 --- a/src/azure-cli/setup.py +++ b/src/azure-cli/setup.py @@ -112,6 +112,7 @@ 'azure-mgmt-relay~=0.1.0', # 'azure-mgmt-reservations~=0.6.0', 'azure-mgmt-reservations==0.6.0', # TODO: Use requirements.txt instead of '==' #9781 + 'azure-mgmt-resource==10.2.0', 'azure-mgmt-search~=2.0', 'azure-mgmt-security~=0.4.1', 'azure-mgmt-servicebus~=0.6.0', From 3147c9906f45922cdb0c0cf77f4a202649d743c7 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Thu, 29 Oct 2020 15:19:43 +0800 Subject: [PATCH 02/11] Add switch _USE_VENDEROED_SUBSCRIPTION_SDK --- src/azure-cli-core/azure/cli/core/_profile.py | 30 ++++++++++++------- .../azure/cli/core/tests/test_profile.py | 11 +++++-- .../core/tests/test_profile_v2016_06_01.py | 12 ++++++-- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 09df128bd4d..efe2a6c7c05 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -78,6 +78,8 @@ _AZ_LOGIN_MESSAGE = "Please run 'az login' to setup account." +_USE_VENDEROED_SUBSCRIPTION_SDK = True + def load_subscriptions(cli_ctx, all_clouds=False, refresh=False): profile = Profile(cli_ctx=cli_ctx) @@ -295,11 +297,18 @@ def _build_tenant_level_accounts(self, tenants): return result def _new_account(self): - from azure.cli.core.profiles import ResourceType, get_sdk - SubscriptionType, StateType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, 'Subscription', - 'SubscriptionState', mod='models') + if _USE_VENDEROED_SUBSCRIPTION_SDK: + from azure.cli.core.vendored_sdks.subscriptions.models import Subscription + from azure.cli.core.vendored_sdks.subscriptions.models import SubscriptionState + SubscriptionType = Subscription + StateType = SubscriptionState + else: + from azure.cli.core.profiles import ResourceType, get_sdk + SubscriptionType, StateType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, + 'Subscription', + 'SubscriptionState', mod='models') s = SubscriptionType() - s.state = StateType.enabled + s.state = StateType.ENABLED return s def find_subscriptions_in_vm_with_msi(self, identity_id=None, allow_no_subscriptions=None): @@ -441,8 +450,7 @@ def _match_account(account, subscription_id, secondary_key_name, secondary_key_v @staticmethod def _pick_working_subscription(subscriptions): - from azure.mgmt.resource.subscriptions.models import SubscriptionState - s = next((x for x in subscriptions if x.get(_STATE) == SubscriptionState.enabled.value), None) + s = next((x for x in subscriptions if x.get(_STATE) == 'Enabled'), None) return s or subscriptions[0] def is_tenant_level_account(self): @@ -816,7 +824,7 @@ def create_arm_client_factory(credentials): from azure.cli.core.profiles import ResourceType, get_api_version from azure.cli.core.commands.client_factory import _prepare_client_kwargs_track2 - client_type = self._get_subscription_client_class(use_vendored_sdk=True) + client_type = self._get_subscription_client_class() api_version = get_api_version(cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) client_kwargs = _prepare_client_kwargs_track2(cli_ctx) # We don't need to change credential_scopes as 'scopes' is ignored by BasicTokenCredential anyway @@ -987,18 +995,18 @@ def _find_using_specific_tenant(self, tenant, access_token): self.tenants.append(tenant) return all_subscriptions - def _get_subscription_client_class(self, use_vendored_sdk=False): # pylint: disable=no-self-use + def _get_subscription_client_class(self): # pylint: disable=no-self-use """Get the subscription client class. It can come from either the vendored SDK or public SDK, depending on the design of architecture. """ - if use_vendored_sdk: + if _USE_VENDEROED_SUBSCRIPTION_SDK: # Use vendered subscription SDK to decouple from `resource` command module from azure.cli.core.vendored_sdks.subscriptions import SubscriptionClient client_type = SubscriptionClient else: - from azure.cli.core.profiles._shared import get_client_class - from azure.cli.core.profiles import ResourceType # Use the public SDK + from azure.cli.core.profiles import ResourceType + from azure.cli.core.profiles._shared import get_client_class client_type = get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) return client_type diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index e5026de8416..3eaf05d0381 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -14,11 +14,16 @@ from copy import deepcopy from adal import AdalError -from azure.mgmt.resource.subscriptions.models import \ - (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit, ManagedByTenant) from azure.cli.core._profile import (Profile, CredsCache, SubscriptionFinder, - ServicePrincipalAuth, _AUTH_CTX_FACTORY) + ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDEROED_SUBSCRIPTION_SDK) +if _USE_VENDEROED_SUBSCRIPTION_SDK: + from azure.cli.core.vendored_sdks.subscriptions.models import \ + (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit, ManagedByTenant) +else: + from azure.mgmt.resource.subscriptions.models import \ + (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit, ManagedByTenant) + from azure.cli.core.mock import DummyCli from knack.util import CLIError diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py index f36d43057b3..110f59c481d 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py @@ -14,11 +14,17 @@ from copy import deepcopy from adal import AdalError -from azure.mgmt.resource.subscriptions.v2016_06_01.models import \ - (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit) from azure.cli.core._profile import (Profile, CredsCache, SubscriptionFinder, - ServicePrincipalAuth, _AUTH_CTX_FACTORY) + ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDEROED_SUBSCRIPTION_SDK) + +if _USE_VENDEROED_SUBSCRIPTION_SDK: + from azure.cli.core.vendored_sdks.subscriptions.v2016_06_01.models import \ + (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit) +else: + from azure.mgmt.resource.subscriptions.v2016_06_01.models import \ + (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit) + from azure.cli.core.mock import DummyCli from knack.util import CLIError From a35910ce1a2089ac2928e62752786df8c3c141d6 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Thu, 29 Oct 2020 17:22:58 +0800 Subject: [PATCH 03/11] Add __init__ --- .../azure/cli/core/vendored_sdks/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/__init__.py diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/__init__.py new file mode 100644 index 00000000000..7ccdb55ab6d --- /dev/null +++ b/src/azure-cli-core/azure/cli/core/vendored_sdks/__init__.py @@ -0,0 +1,7 @@ +# 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 2e7d18e3d091ea3bf8615e025537392830f5ca94 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Thu, 29 Oct 2020 18:10:13 +0800 Subject: [PATCH 04/11] Use find_packages --- .../subscriptions/v2016_06_01/aio/__init__.py | 10 - .../v2016_06_01/aio/_configuration.py | 60 -- .../v2016_06_01/aio/_subscription_client.py | 71 --- .../v2016_06_01/aio/operations/__init__.py | 19 - .../v2016_06_01/aio/operations/_operations.py | 104 ---- .../_subscription_client_operations.py | 83 --- .../operations/_subscriptions_operations.py | 229 -------- .../aio/operations/_tenants_operations.py | 104 ---- .../subscriptions/v2018_06_01/__init__.py | 16 - .../v2018_06_01/_configuration.py | 64 --- .../subscriptions/v2018_06_01/_metadata.json | 62 -- .../v2018_06_01/_subscription_client.py | 77 --- .../subscriptions/v2018_06_01/aio/__init__.py | 10 - .../v2018_06_01/aio/_configuration.py | 60 -- .../v2018_06_01/aio/_subscription_client.py | 71 --- .../v2018_06_01/aio/operations/__init__.py | 19 - .../v2018_06_01/aio/operations/_operations.py | 104 ---- .../_subscription_client_operations.py | 83 --- .../operations/_subscriptions_operations.py | 229 -------- .../aio/operations/_tenants_operations.py | 104 ---- .../v2018_06_01/models/__init__.py | 64 --- .../v2018_06_01/models/_models.py | 463 --------------- .../v2018_06_01/models/_models_py3.py | 501 ---------------- .../models/_subscription_client_enums.py | 52 -- .../v2018_06_01/operations/__init__.py | 19 - .../v2018_06_01/operations/_operations.py | 109 ---- .../_subscription_client_operations.py | 88 --- .../operations/_subscriptions_operations.py | 236 -------- .../operations/_tenants_operations.py | 109 ---- .../subscriptions/v2018_06_01/py.typed | 1 - .../subscriptions/v2019_06_01/__init__.py | 16 - .../v2019_06_01/_configuration.py | 64 --- .../subscriptions/v2019_06_01/_metadata.json | 62 -- .../v2019_06_01/_subscription_client.py | 77 --- .../subscriptions/v2019_06_01/aio/__init__.py | 10 - .../v2019_06_01/aio/_configuration.py | 60 -- .../v2019_06_01/aio/_subscription_client.py | 71 --- .../v2019_06_01/aio/operations/__init__.py | 19 - .../v2019_06_01/aio/operations/_operations.py | 104 ---- .../_subscription_client_operations.py | 83 --- .../operations/_subscriptions_operations.py | 229 -------- .../aio/operations/_tenants_operations.py | 104 ---- .../v2019_06_01/models/__init__.py | 69 --- .../v2019_06_01/models/_models.py | 500 ---------------- .../v2019_06_01/models/_models_py3.py | 539 ------------------ .../models/_subscription_client_enums.py | 60 -- .../v2019_06_01/operations/__init__.py | 19 - .../v2019_06_01/operations/_operations.py | 109 ---- .../_subscription_client_operations.py | 88 --- .../operations/_subscriptions_operations.py | 236 -------- .../operations/_tenants_operations.py | 109 ---- .../subscriptions/v2019_06_01/py.typed | 1 - .../subscriptions/v2019_11_01/aio/__init__.py | 10 - .../v2019_11_01/aio/_configuration.py | 60 -- .../v2019_11_01/aio/_subscription_client.py | 71 --- .../v2019_11_01/aio/operations/__init__.py | 19 - .../v2019_11_01/aio/operations/_operations.py | 104 ---- .../_subscription_client_operations.py | 83 --- .../operations/_subscriptions_operations.py | 229 -------- .../aio/operations/_tenants_operations.py | 104 ---- src/azure-cli-core/setup.py | 9 +- 61 files changed, 2 insertions(+), 6537 deletions(-) delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py delete mode 100644 src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py deleted file mode 100644 index 25a76f1a699..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py deleted file mode 100644 index 92539d2f67d..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - 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.api_version = "2016-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py deleted file mode 100644 index 6dd814071c6..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/_subscription_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import 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 import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - 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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py deleted file mode 100644 index 79a97b3cff3..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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.OperationListResult"]: - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py deleted file mode 100644 index d9614d6ec24..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin: - - async def check_resource_name( - self, - resource_name_definition: Optional["models.ResourceName"] = None, - **kwargs - ) -> "models.CheckResourceNameResult": - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py deleted file mode 100644 index 3afeddc430b..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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_locations( - self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["models.LocationListResult"]: - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - async def get( - self, - subscription_id: str, - **kwargs - ) -> "models.Subscription": - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs - ) -> AsyncIterable["models.SubscriptionListResult"]: - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py deleted file mode 100644 index ee13e72c0e7..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.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[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py deleted file mode 100644 index a1d3eed7425..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py deleted file mode 100644 index 2fe47dd5c19..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.credentials import TokenCredential - -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.TokenCredential - """ - - 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.api_version = "2018-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json deleted file mode 100644 index a9b7fbf364b..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_metadata.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "chosen_version": "2018-06-01", - "total_api_version_list": ["2018-06-01"], - "client": { - "name": "SubscriptionClient", - "filename": "_subscription_client", - "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": false - }, - "global_parameters": { - "sync_method": { - "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - } - }, - "async_method": { - "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential" - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null - }, - "operation_groups": { - "operations": "Operations", - "subscriptions": "SubscriptionsOperations", - "tenants": "TenantsOperations" - }, - "operation_mixins": { - "check_resource_name" : { - "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" - } - }, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" -} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py deleted file mode 100644 index 8720f19331a..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/_subscription_client.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -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 Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - """ - - def __init__( - 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._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py deleted file mode 100644 index 25a76f1a699..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py deleted file mode 100644 index 387cd5c7a70..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - 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.api_version = "2018-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py deleted file mode 100644 index 661f9572726..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/_subscription_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import 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 import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - 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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py deleted file mode 100644 index 871caa4e83f..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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.OperationListResult"]: - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py deleted file mode 100644 index 7ef0546f009..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin: - - async def check_resource_name( - self, - resource_name_definition: Optional["models.ResourceName"] = None, - **kwargs - ) -> "models.CheckResourceNameResult": - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py deleted file mode 100644 index 11a3c2bb503..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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_locations( - self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["models.LocationListResult"]: - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - async def get( - self, - subscription_id: str, - **kwargs - ) -> "models.Subscription": - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs - ) -> AsyncIterable["models.SubscriptionListResult"]: - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py deleted file mode 100644 index 32c40c32f1e..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py deleted file mode 100644 index 4d3bb8b7d25..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/__init__.py +++ /dev/null @@ -1,64 +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. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import CheckResourceNameResult - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorResponse - from ._models_py3 import Location - from ._models_py3 import LocationListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import ResourceName - from ._models_py3 import Subscription - from ._models_py3 import SubscriptionListResult - from ._models_py3 import SubscriptionPolicies - from ._models_py3 import TenantIdDescription - from ._models_py3 import TenantListResult -except (SyntaxError, ImportError): - from ._models import CheckResourceNameResult # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Location # type: ignore - from ._models import LocationListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import ResourceName # type: ignore - from ._models import Subscription # type: ignore - from ._models import SubscriptionListResult # 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 ( - ResourceNameStatus, - SpendingLimit, - SubscriptionState, -) - -__all__ = [ - 'CheckResourceNameResult', - 'ErrorDefinition', - 'ErrorResponse', - 'Location', - 'LocationListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py deleted file mode 100644 index e7f7b644f9b..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models.py +++ /dev/null @@ -1,463 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class CheckResourceNameResult(msrest.serialization.Model): - """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", - "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckResourceNameResult, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.status = kwargs.get('status', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why resource name is invalid. - - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.code = kwargs.get('code', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, 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 LocationListResult(msrest.serialization.Model): - """Location list operation response. - - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 Operation(msrest.serialization.Model): - """Microsoft.Resources operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :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 - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - 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) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceName(msrest.serialization.Model): - """Name and Type of the Resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceName, self).__init__(**kwargs) - self.name = kwargs['name'] - self.type = kwargs['type'] - - -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 tenant_id: The subscription tenant ID. - :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: - ~azure.mgmt.resource.subscriptions.v2018_06_01.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}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', '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.tenant_id = None - self.state = None - self.subscription_policies = kwargs.get('subscription_policies', None) - self.authorization_source = kwargs.get('authorization_source', None) - - -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[~azure.mgmt.resource.subscriptions.v2018_06_01.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 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 - ~azure.mgmt.resource.subscriptions.v2018_06_01.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 - :ivar country: Country/region name of the address for the tenant. - :vartype country: str - :ivar country_code: Country/region abbreviation for the tenant. - :vartype country_code: str - :ivar display_name: The display name of the tenant. - :vartype display_name: str - :ivar domains: The list of domains for the tenant. - :vartype domains: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - self.country = None - self.country_code = None - self.display_name = None - self.domains = 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[~azure.mgmt.resource.subscriptions.v2018_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py deleted file mode 100644 index c0e1457f1a7..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_models_py3.py +++ /dev/null @@ -1,501 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, Optional, Union - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - -from ._subscription_client_enums import * - - -class CheckResourceNameResult(msrest.serialization.Model): - """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", - "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, - **kwargs - ): - super(CheckResourceNameResult, self).__init__(**kwargs) - self.name = name - self.type = type - self.status = status - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why resource name is invalid. - - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.message = message - self.code = code - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): - super(ErrorResponse, 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 - - -class LocationListResult(msrest.serialization.Model): - """Location list operation response. - - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 Operation(msrest.serialization.Model): - """Microsoft.Resources operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - 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(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :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 - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - 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 ResourceName(msrest.serialization.Model): - """Name and Type of the Resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): - super(ResourceName, self).__init__(**kwargs) - self.name = name - self.type = type - - -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 tenant_id: The subscription tenant ID. - :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: - ~azure.mgmt.resource.subscriptions.v2018_06_01.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}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', '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.tenant_id = None - self.state = None - self.subscription_policies = subscription_policies - self.authorization_source = authorization_source - - -class SubscriptionListResult(msrest.serialization.Model): - """Subscription list operation response. - - All required parameters must be populated in order to send to Azure. - - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.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 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 - ~azure.mgmt.resource.subscriptions.v2018_06_01.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 - :ivar country: Country/region name of the address for the tenant. - :vartype country: str - :ivar country_code: Country/region abbreviation for the tenant. - :vartype country_code: str - :ivar display_name: The display name of the tenant. - :vartype display_name: str - :ivar domains: The list of domains for the tenant. - :vartype domains: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - self.country = None - self.country_code = None - self.display_name = None - self.domains = 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[~azure.mgmt.resource.subscriptions.v2018_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py deleted file mode 100644 index cec9f01471e..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/models/_subscription_client_enums.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ - - ALLOWED = "Allowed" - RESERVED = "Reserved" - -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ - - ON = "On" - OFF = "Off" - CURRENT_PERIOD_OFF = "CurrentPeriodOff" - -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ - - ENABLED = "Enabled" - WARNED = "Warned" - PAST_DUE = "PastDue" - DISABLED = "Disabled" - DELETED = "Deleted" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py deleted file mode 100644 index a654caa6c06..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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.OperationListResult"] - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py deleted file mode 100644 index f43b9a9a880..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscription_client_operations.py +++ /dev/null @@ -1,88 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin(object): - - def check_resource_name( - self, - resource_name_definition=None, # type: Optional["models.ResourceName"] - **kwargs # type: Any - ): - # type: (...) -> "models.CheckResourceNameResult" - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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]: - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py deleted file mode 100644 index 3062a750e69..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_subscriptions_operations.py +++ /dev/null @@ -1,236 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_locations( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.LocationListResult"] - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - def get( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Subscription" - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.SubscriptionListResult"] - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py deleted file mode 100644 index ba68b8c7e4f..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/operations/_tenants_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations(object): - """TenantsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.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[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2018_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py deleted file mode 100644 index a1d3eed7425..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py deleted file mode 100644 index 2be8dc9ddd2..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.credentials import TokenCredential - -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.TokenCredential - """ - - 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.api_version = "2019-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json deleted file mode 100644 index eb91cd1a145..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_metadata.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "chosen_version": "2019-06-01", - "total_api_version_list": ["2019-06-01"], - "client": { - "name": "SubscriptionClient", - "filename": "_subscription_client", - "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": false - }, - "global_parameters": { - "sync_method": { - "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - } - }, - "async_method": { - "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential" - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null - }, - "operation_groups": { - "operations": "Operations", - "subscriptions": "SubscriptionsOperations", - "tenants": "TenantsOperations" - }, - "operation_mixins": { - "check_resource_name" : { - "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"models.ResourceName\"] = None,\n **kwargs\n) -\u003e \"models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_name_definition" - } - }, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}" -} \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py deleted file mode 100644 index 5d72fa82597..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/_subscription_client.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -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 Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - """ - - def __init__( - 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._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py deleted file mode 100644 index 25a76f1a699..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py deleted file mode 100644 index 9c42a86df36..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - 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.api_version = "2019-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py deleted file mode 100644 index 771cb77eac3..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/_subscription_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import 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 import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - 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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py deleted file mode 100644 index c2bd4e487d4..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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.OperationListResult"]: - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py deleted file mode 100644 index b781a886fde..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin: - - async def check_resource_name( - self, - resource_name_definition: Optional["models.ResourceName"] = None, - **kwargs - ) -> "models.CheckResourceNameResult": - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py deleted file mode 100644 index 3c9d13f4f06..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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_locations( - self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["models.LocationListResult"]: - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - async def get( - self, - subscription_id: str, - **kwargs - ) -> "models.Subscription": - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs - ) -> AsyncIterable["models.SubscriptionListResult"]: - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py deleted file mode 100644 index 1cf2211d3bd..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py deleted file mode 100644 index 7dccb979f7c..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/__init__.py +++ /dev/null @@ -1,69 +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. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import CheckResourceNameResult - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorResponse - from ._models_py3 import Location - from ._models_py3 import LocationListResult - from ._models_py3 import ManagedByTenant - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import ResourceName - from ._models_py3 import Subscription - from ._models_py3 import SubscriptionListResult - from ._models_py3 import SubscriptionPolicies - from ._models_py3 import TenantIdDescription - from ._models_py3 import TenantListResult -except (SyntaxError, ImportError): - from ._models import CheckResourceNameResult # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Location # type: ignore - from ._models import LocationListResult # type: ignore - from ._models import ManagedByTenant # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import ResourceName # type: ignore - from ._models import Subscription # type: ignore - from ._models import SubscriptionListResult # 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 ( - ResourceNameStatus, - SpendingLimit, - SubscriptionState, - TenantCategory, -) - -__all__ = [ - 'CheckResourceNameResult', - 'ErrorDefinition', - 'ErrorResponse', - 'Location', - 'LocationListResult', - 'ManagedByTenant', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'ResourceName', - 'Subscription', - 'SubscriptionListResult', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', - 'ResourceNameStatus', - 'SpendingLimit', - 'SubscriptionState', - 'TenantCategory', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py deleted file mode 100644 index 098139fbac4..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models.py +++ /dev/null @@ -1,500 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class CheckResourceNameResult(msrest.serialization.Model): - """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", - "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckResourceNameResult, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.status = kwargs.get('status', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why resource name is invalid. - - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.code = kwargs.get('code', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, 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 LocationListResult(msrest.serialization.Model): - """Location list operation response. - - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.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 ManagedByTenant(msrest.serialization.Model): - """Information about a tenant managing the subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. - :vartype tenant_id: str - """ - - _validation = { - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedByTenant, self).__init__(**kwargs) - self.tenant_id = None - - -class Operation(msrest.serialization.Model): - """Microsoft.Resources operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :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 - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - 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) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceName(msrest.serialization.Model): - """Name and Type of the Resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceName, self).__init__(**kwargs) - self.name = kwargs['name'] - self.type = kwargs['type'] - - -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 tenant_id: The subscription tenant ID. - :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: - ~azure.mgmt.resource.subscriptions.v2019_06_01.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 - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: - list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] - """ - - _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, - 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, - } - - def __init__( - self, - **kwargs - ): - super(Subscription, self).__init__(**kwargs) - self.id = None - self.subscription_id = None - self.display_name = None - self.tenant_id = None - self.state = None - self.subscription_policies = kwargs.get('subscription_policies', None) - self.authorization_source = kwargs.get('authorization_source', None) - self.managed_by_tenants = kwargs.get('managed_by_tenants', None) - - -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[~azure.mgmt.resource.subscriptions.v2019_06_01.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 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 - ~azure.mgmt.resource.subscriptions.v2019_06_01.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 - :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", - "ManagedBy". - :vartype tenant_category: str or - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory - :ivar country: Country/region name of the address for the tenant. - :vartype country: str - :ivar country_code: Country/region abbreviation for the tenant. - :vartype country_code: str - :ivar display_name: The display name of the tenant. - :vartype display_name: str - :ivar domains: The list of domains for the tenant. - :vartype domains: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'tenant_category': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - self.tenant_category = None - self.country = None - self.country_code = None - self.display_name = None - self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py deleted file mode 100644 index 9187caff6e2..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_models_py3.py +++ /dev/null @@ -1,539 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, Optional, Union - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - -from ._subscription_client_enums import * - - -class CheckResourceNameResult(msrest.serialization.Model): - """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", - "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - status: Optional[Union[str, "ResourceNameStatus"]] = None, - **kwargs - ): - super(CheckResourceNameResult, self).__init__(**kwargs) - self.name = name - self.type = type - self.status = status - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why resource name is invalid. - - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - *, - message: Optional[str] = None, - code: Optional[str] = None, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.message = message - self.code = code - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): - super(ErrorResponse, 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 - - -class LocationListResult(msrest.serialization.Model): - """Location list operation response. - - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.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 ManagedByTenant(msrest.serialization.Model): - """Information about a tenant managing the subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. - :vartype tenant_id: str - """ - - _validation = { - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedByTenant, self).__init__(**kwargs) - self.tenant_id = None - - -class Operation(msrest.serialization.Model): - """Microsoft.Resources operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - 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(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :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 - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - 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 ResourceName(msrest.serialization.Model): - """Name and Type of the Resource. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - type: str, - **kwargs - ): - super(ResourceName, self).__init__(**kwargs) - self.name = name - self.type = type - - -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 tenant_id: The subscription tenant ID. - :vartype tenant_id: 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 ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: - ~azure.mgmt.resource.subscriptions.v2019_06_01.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 - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: - list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] - """ - - _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, - 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, - 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, - } - - def __init__( - self, - *, - subscription_policies: Optional["SubscriptionPolicies"] = None, - authorization_source: Optional[str] = None, - managed_by_tenants: Optional[List["ManagedByTenant"]] = None, - **kwargs - ): - super(Subscription, self).__init__(**kwargs) - self.id = None - self.subscription_id = None - self.display_name = None - self.tenant_id = None - self.state = None - self.subscription_policies = subscription_policies - self.authorization_source = authorization_source - self.managed_by_tenants = managed_by_tenants - - -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[~azure.mgmt.resource.subscriptions.v2019_06_01.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 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 - ~azure.mgmt.resource.subscriptions.v2019_06_01.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 - :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", - "ManagedBy". - :vartype tenant_category: str or - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory - :ivar country: Country/region name of the address for the tenant. - :vartype country: str - :ivar country_code: Country/region abbreviation for the tenant. - :vartype country_code: str - :ivar display_name: The display name of the tenant. - :vartype display_name: str - :ivar domains: The list of domains for the tenant. - :vartype domains: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'tenant_category': {'readonly': True}, - 'country': {'readonly': True}, - 'country_code': {'readonly': True}, - 'display_name': {'readonly': True}, - 'domains': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'domains': {'key': 'domains', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - self.tenant_category = None - self.country = None - self.country_code = None - self.display_name = None - self.domains = 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[~azure.mgmt.resource.subscriptions.v2019_06_01.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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py deleted file mode 100644 index 22d3c785556..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/models/_subscription_client_enums.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Is the resource name Allowed or Reserved - """ - - ALLOWED = "Allowed" - RESERVED = "Reserved" - -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. - """ - - ON = "On" - OFF = "Off" - CURRENT_PERIOD_OFF = "CurrentPeriodOff" - -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - """ - - ENABLED = "Enabled" - WARNED = "Warned" - PAST_DUE = "PastDue" - DISABLED = "Disabled" - DELETED = "Deleted" - -class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The tenant category. - """ - - HOME = "Home" - PROJECTED_BY = "ProjectedBy" - MANAGED_BY = "ManagedBy" diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py deleted file mode 100644 index 65378646244..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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.OperationListResult"] - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py deleted file mode 100644 index 108314fb8f8..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscription_client_operations.py +++ /dev/null @@ -1,88 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin(object): - - def check_resource_name( - self, - resource_name_definition=None, # type: Optional["models.ResourceName"] - **kwargs # type: Any - ): - # type: (...) -> "models.CheckResourceNameResult" - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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]: - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py deleted file mode 100644 index 964156397dc..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_subscriptions_operations.py +++ /dev/null @@ -1,236 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_locations( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.LocationListResult"] - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - def get( - self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Subscription" - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.SubscriptionListResult"] - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py deleted file mode 100644 index fe5804617e2..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/operations/_tenants_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations(object): - """TenantsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.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[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py deleted file mode 100644 index 25a76f1a699..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient'] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py deleted file mode 100644 index e1994b337ed..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - 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.api_version = "2019-11-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py deleted file mode 100644 index aa1e8a2bdfe..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/_subscription_client.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import 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 import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - -class SubscriptionClient(SubscriptionClientOperationsMixin): - """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.Operations - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.TenantsOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - """ - - 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._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - 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/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py deleted file mode 100644 index 228a89205db..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations -from ._subscription_client_operations import SubscriptionClientOperationsMixin - -__all__ = [ - 'Operations', - 'SubscriptionsOperations', - 'TenantsOperations', - 'SubscriptionClientOperationsMixin', -] diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py deleted file mode 100644 index d2311754ea1..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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.OperationListResult"]: - """Lists all of the available Microsoft.Resources REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', 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': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py deleted file mode 100644 index 679c2ab2fd5..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionClientOperationsMixin: - - async def check_resource_name( - self, - resource_name_definition: Optional["models.ResourceName"] = None, - **kwargs - ) -> "models.CheckResourceNameResult": - """Checks resource name validity. - - A resource name is valid if it is not a reserved word, does not contains a reserved word and - does not start with a reserved word. - - :param resource_name_definition: Resource object with values for resource name and resource - type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckResourceNameResult, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CheckResourceNameResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') - else: - body_content = None - 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('CheckResourceNameResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py deleted file mode 100644 index 95883e6835d..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """SubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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_locations( - self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["models.LocationListResult"]: - """Gets all available geo-locations. - - This operation provides all the locations that are available for resource providers; however, - each resource provider may support a subset of this list. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore - - async def get( - self, - subscription_id: str, - **kwargs - ) -> "models.Subscription": - """Gets details about a specified subscription. - - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Subscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore - - def list( - self, - **kwargs - ) -> AsyncIterable["models.SubscriptionListResult"]: - """Gets all subscriptions for a tenant. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py b/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py deleted file mode 100644 index 2007d467330..00000000000 --- a/src/azure-cli-core/azure/cli/core/vendored_sdks/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.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[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - 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/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index 85794f56f71..1700e8146c2 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -7,7 +7,7 @@ from __future__ import print_function from codecs import open -from setuptools import setup +from setuptools import setup, find_packages VERSION = "2.14.0" @@ -86,12 +86,7 @@ url='https://github.com/Azure/azure-cli', zip_safe=False, classifiers=CLASSIFIERS, - packages=[ - 'azure.cli.core', - 'azure.cli.core.commands', - 'azure.cli.core.extension', - 'azure.cli.core.profiles', - ], + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests", "azure", "azure.cli"]), install_requires=DEPENDENCIES, extras_require={ ":python_version<'3.4'": ['enum34'], From f4cec0a412753fb941094084c73c8cfae145b332 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Wed, 4 Nov 2020 10:34:54 +0800 Subject: [PATCH 05/11] Tab to space --- .flake8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 2df4f07750f..d61f6cef6bc 100644 --- a/.flake8 +++ b/.flake8 @@ -18,5 +18,5 @@ exclude = scripts doc build_scripts - */grammar/ - vendored_sdks + */grammar/ + vendored_sdks From 2bdd5f259f835fe3faa6974c07f5ba3c2353ff8b Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Thu, 5 Nov 2020 17:03:28 +0800 Subject: [PATCH 06/11] Typo --- src/azure-cli-core/azure/cli/core/_profile.py | 6 +++--- src/azure-cli-core/azure/cli/core/tests/test_profile.py | 4 ++-- .../azure/cli/core/tests/test_profile_v2016_06_01.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index efe2a6c7c05..2e907a4c275 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -78,7 +78,7 @@ _AZ_LOGIN_MESSAGE = "Please run 'az login' to setup account." -_USE_VENDEROED_SUBSCRIPTION_SDK = True +_USE_VENDORED_SUBSCRIPTION_SDK = True def load_subscriptions(cli_ctx, all_clouds=False, refresh=False): @@ -297,7 +297,7 @@ def _build_tenant_level_accounts(self, tenants): return result def _new_account(self): - if _USE_VENDEROED_SUBSCRIPTION_SDK: + if _USE_VENDORED_SUBSCRIPTION_SDK: from azure.cli.core.vendored_sdks.subscriptions.models import Subscription from azure.cli.core.vendored_sdks.subscriptions.models import SubscriptionState SubscriptionType = Subscription @@ -999,7 +999,7 @@ def _get_subscription_client_class(self): # pylint: disable=no-self-use """Get the subscription client class. It can come from either the vendored SDK or public SDK, depending on the design of architecture. """ - if _USE_VENDEROED_SUBSCRIPTION_SDK: + if _USE_VENDORED_SUBSCRIPTION_SDK: # Use vendered subscription SDK to decouple from `resource` command module from azure.cli.core.vendored_sdks.subscriptions import SubscriptionClient client_type = SubscriptionClient diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index 3eaf05d0381..53a9076570f 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -16,8 +16,8 @@ from adal import AdalError from azure.cli.core._profile import (Profile, CredsCache, SubscriptionFinder, - ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDEROED_SUBSCRIPTION_SDK) -if _USE_VENDEROED_SUBSCRIPTION_SDK: + ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDORED_SUBSCRIPTION_SDK) +if _USE_VENDORED_SUBSCRIPTION_SDK: from azure.cli.core.vendored_sdks.subscriptions.models import \ (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit, ManagedByTenant) else: diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py index 110f59c481d..4dfb7a62cbf 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile_v2016_06_01.py @@ -16,9 +16,9 @@ from adal import AdalError from azure.cli.core._profile import (Profile, CredsCache, SubscriptionFinder, - ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDEROED_SUBSCRIPTION_SDK) + ServicePrincipalAuth, _AUTH_CTX_FACTORY, _USE_VENDORED_SUBSCRIPTION_SDK) -if _USE_VENDEROED_SUBSCRIPTION_SDK: +if _USE_VENDORED_SUBSCRIPTION_SDK: from azure.cli.core.vendored_sdks.subscriptions.v2016_06_01.models import \ (SubscriptionState, Subscription, SubscriptionPolicies, SpendingLimit) else: From a216f4ef30ef213f33e2eac735947c3c96b25d75 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Mon, 16 Nov 2020 10:11:23 +0800 Subject: [PATCH 07/11] Refine _new_account --- src/azure-cli-core/azure/cli/core/_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index fffe7e946e1..0aeb5dc8a29 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -305,18 +305,18 @@ def _build_tenant_level_accounts(self, tenants): return result def _new_account(self): + """Build an empty Subscription which will be used as a tenant account. + API version doesn't matter as only specified attributes are preserved by _normalize_properties.""" if _USE_VENDORED_SUBSCRIPTION_SDK: from azure.cli.core.vendored_sdks.subscriptions.models import Subscription - from azure.cli.core.vendored_sdks.subscriptions.models import SubscriptionState SubscriptionType = Subscription - StateType = SubscriptionState else: from azure.cli.core.profiles import ResourceType, get_sdk SubscriptionType, StateType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, 'Subscription', 'SubscriptionState', mod='models') s = SubscriptionType() - s.state = StateType.ENABLED + s.state = 'Enabled' return s def find_subscriptions_in_vm_with_msi(self, identity_id=None, allow_no_subscriptions=None): From 83fe6a14c51931f3840c3c525369c7ca709d50e2 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Mon, 16 Nov 2020 11:04:30 +0800 Subject: [PATCH 08/11] Style --- src/azure-cli-core/azure/cli/core/_profile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/_profile.py b/src/azure-cli-core/azure/cli/core/_profile.py index 0aeb5dc8a29..4fd20243eff 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -312,9 +312,8 @@ def _new_account(self): SubscriptionType = Subscription else: from azure.cli.core.profiles import ResourceType, get_sdk - SubscriptionType, StateType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, - 'Subscription', - 'SubscriptionState', mod='models') + SubscriptionType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, + 'Subscription', mod='models') s = SubscriptionType() s.state = 'Enabled' return s @@ -834,6 +833,7 @@ def create_arm_client_factory(credentials): client_type = self._get_subscription_client_class() if client_type is None: + from azure.cli.core.azclierror import CLIInternalError raise CLIInternalError("Unable to get '{}' in profile '{}'" .format(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, cli_ctx.cloud.profile)) api_version = get_api_version(cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS) From 5ecb89ac65a790cfc5eb59ef5dc112598445455d Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Mon, 16 Nov 2020 11:11:50 +0800 Subject: [PATCH 09/11] Dependency --- src/azure-cli-core/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index 26d60c70d9b..7bf13472be7 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -59,7 +59,7 @@ 'requests~=2.22', 'six~=1.12', 'pkginfo>=1.5.0.1', - 'azure-mgmt-core==1.2.1' + 'azure-mgmt-core==1.2.1', # Dependencies of the vendored subscription SDK # https://github.com/Azure/azure-sdk-for-python/blob/ab12b048ddf676fe0ccec16b2167117f0609700d/sdk/resources/azure-mgmt-resource/setup.py#L82-L86 'msrest>=0.5.0', From 8ff4b542e0cd60458a71aaaa4644ed8930bd0271 Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Mon, 16 Nov 2020 13:19:15 +0800 Subject: [PATCH 10/11] Fix test_subscription_finder_fail_on_arm_client_factory --- src/azure-cli-core/azure/cli/core/tests/test_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index 053b8d33892..f1c78217095 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -321,7 +321,7 @@ def test_subscription_finder_constructor(self, get_api_mock): result = finder._arm_client_factory(mock.MagicMock()) self.assertEqual(result._client._base_url, 'http://foo_arm') - @mock.patch('azure.cli.core.profiles._shared.get_client_class', autospec=True) + @mock.patch('azure.cli.core._profile.SubscriptionFinder._get_subscription_client_class', autospec=True) def test_subscription_finder_fail_on_arm_client_factory(self, get_client_class_mock): cli = DummyCli() get_client_class_mock.return_value = None From 081d233a33e6f638109c39528a28105c61c2f54f Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Wed, 18 Nov 2020 13:11:54 +0800 Subject: [PATCH 11/11] Add comments --- src/azure-cli-core/azure/cli/core/adal_authentication.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/azure-cli-core/azure/cli/core/adal_authentication.py b/src/azure-cli-core/azure/cli/core/adal_authentication.py index 01796408a84..3bc28b0d1d6 100644 --- a/src/azure-cli-core/azure/cli/core/adal_authentication.py +++ b/src/azure-cli-core/azure/cli/core/adal_authentication.py @@ -175,9 +175,12 @@ def _try_scopes_to_resource(scopes): class BasicTokenCredential: # pylint:disable=too-few-public-methods - """A Track 2 implementation of msrest.authentication.BasicTokenAuthentication.""" + """A Track 2 implementation of msrest.authentication.BasicTokenAuthentication. + This credential shouldn't be used by any command module, expect azure-cli-core. + """ def __init__(self, access_token): self.access_token = access_token def get_token(self, *scopes, **kwargs): # pylint:disable=unused-argument + # Because get_token can't refresh the access token, always mark the token as unexpired return AccessToken(self.access_token, int(time.time() + 3600))