diff --git a/.flake8 b/.flake8 index 2f18f729601..d61f6cef6bc 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 b45ae4605c8..4fd20243eff 100644 --- a/src/azure-cli-core/azure/cli/core/_profile.py +++ b/src/azure-cli-core/azure/cli/core/_profile.py @@ -77,6 +77,8 @@ _AZ_LOGIN_MESSAGE = "Please run 'az login' to setup account." +_USE_VENDORED_SUBSCRIPTION_SDK = True + def load_subscriptions(cli_ctx, all_clouds=False, refresh=False): profile = Profile(cli_ctx=cli_ctx) @@ -258,7 +260,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 @@ -303,11 +305,17 @@ 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') + """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 + SubscriptionType = Subscription + else: + from azure.cli.core.profiles import ResourceType, get_sdk + SubscriptionType = get_sdk(self.cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS, + 'Subscription', 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): @@ -449,8 +457,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): @@ -821,18 +828,19 @@ 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 - from azure.cli.core.azclierror import CLIInternalError - 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() 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) + 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 @@ -916,16 +924,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'): @@ -934,6 +943,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 @@ -990,9 +1000,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 = [] @@ -1005,6 +1015,21 @@ def _find_using_specific_tenant(self, tenant, access_token): self.tenants.append(tenant) return all_subscriptions + 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_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: + # 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 + 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 902e2413e38..3bc28b0d1d6 100644 --- a/src/azure-cli-core/azure/cli/core/adal_authentication.py +++ b/src/azure-cli-core/azure/cli/core/adal_authentication.py @@ -171,3 +171,16 @@ def _try_scopes_to_resource(scopes): # Exactly only one scope is provided return scopes_to_resource(scopes) + + +class BasicTokenCredential: + # pylint:disable=too-few-public-methods + """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)) 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 14f8c3d9074..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 @@ -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_VENDORED_SUBSCRIPTION_SDK) +if _USE_VENDORED_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 @@ -314,9 +319,9 @@ 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('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 @@ -1107,7 +1112,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: @@ -1145,7 +1150,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: @@ -1183,7 +1188,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: @@ -1269,7 +1274,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..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 @@ -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_VENDORED_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 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 @@ -294,7 +300,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 +940,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 +978,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 +1016,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 +1102,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/__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. +# -------------------------------------------------------------------------- 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/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/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/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 071494fd9f1..7bf13472be7 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.15.0" @@ -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.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', + 'azure-common~=1.1', ] TESTS_REQUIRE = [ @@ -84,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'], diff --git a/src/azure-cli/setup.py b/src/azure-cli/setup.py index 827278085af..73eb8f17e97 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',