From 319e41bb1aed9c0ba595f067006baf0dbf695868 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 9 Nov 2021 21:29:48 +0000 Subject: [PATCH] CodeGen from PR 16687 in Azure/azure-rest-api-specs Merge 108950b36624ae7a4f1479f66a0d7bdfe03878e6 into f2e08ab373eb0e96b54920e89f9fc96d683355ca --- .../azure-mgmt-subscription/MANIFEST.in | 1 + .../azure-mgmt-subscription/_meta.json | 11 + .../azure/mgmt/subscription/__init__.py | 3 + .../azure/mgmt/subscription/_configuration.py | 4 +- .../azure/mgmt/subscription/_metadata.json | 95 +++ .../mgmt/subscription/_subscription_client.py | 42 +- .../azure/mgmt/subscription/_version.py | 2 +- .../mgmt/subscription/aio/_configuration.py | 4 +- .../subscription/aio/_subscription_client.py | 41 +- .../subscription/aio/operations/__init__.py | 8 +- .../aio/operations/_alias_operations.py | 100 ++- .../operations/_billing_account_operations.py | 95 +++ .../aio/operations/_operations.py | 91 ++- .../operations/_subscription_operations.py | 218 ++++- ....py => _subscription_policy_operations.py} | 156 ++-- .../aio/operations/_tenants_operations.py | 104 --- .../mgmt/subscription/models/__init__.py | 83 +- .../azure/mgmt/subscription/models/_models.py | 703 ++++++++++------ .../mgmt/subscription/models/_models_py3.py | 767 ++++++++++++------ .../models/_subscription_client_enums.py | 33 +- .../mgmt/subscription/operations/__init__.py | 8 +- .../operations/_alias_operations.py | 90 +- .../operations/_billing_account_operations.py | 100 +++ .../subscription/operations/_operations.py | 87 +- .../operations/_subscription_operations.py | 215 ++++- ....py => _subscription_policy_operations.py} | 150 ++-- .../operations/_tenants_operations.py | 109 --- 27 files changed, 2155 insertions(+), 1165 deletions(-) create mode 100644 sdk/subscription/azure-mgmt-subscription/_meta.json create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py rename sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/{_subscriptions_operations.py => _subscription_policy_operations.py} (52%) delete mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py rename sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/{_subscriptions_operations.py => _subscription_policy_operations.py} (53%) delete mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py diff --git a/sdk/subscription/azure-mgmt-subscription/MANIFEST.in b/sdk/subscription/azure-mgmt-subscription/MANIFEST.in index a3cb07df87658..3a9b6517412bc 100644 --- a/sdk/subscription/azure-mgmt-subscription/MANIFEST.in +++ b/sdk/subscription/azure-mgmt-subscription/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/subscription/azure-mgmt-subscription/_meta.json b/sdk/subscription/azure-mgmt-subscription/_meta.json new file mode 100644 index 0000000000000..256b7ef48aea0 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.5", + "use": [ + "@autorest/python@5.8.4", + "@autorest/modelerfour@4.19.2" + ], + "commit": "af9eeae99a8224ceb9b311692f10b39b0e642e43", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/subscription/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "readme": "specification/subscription/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py index a1d3eed7425fc..6d8f45c77a61b 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py @@ -7,6 +7,9 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient +from ._version import VERSION + +__version__ = VERSION __all__ = ['SubscriptionClient'] try: diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py index f4e3e5c64ca80..2a8168883ad65 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py @@ -12,13 +12,14 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from ._version import VERSION + 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. @@ -41,6 +42,7 @@ def __init__( super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json new file mode 100644 index 0000000000000..55dcec15a0825 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json @@ -0,0 +1,95 @@ +{ + "chosen_version": "2021-10-01", + "total_api_version_list": ["2021-10-01"], + "client": { + "name": "SubscriptionClient", + "filename": "_subscription_client", + "description": "The subscription client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "subscription": "SubscriptionOperations", + "operations": "Operations", + "alias": "AliasOperations", + "subscription_policy": "SubscriptionPolicyOperations", + "billing_account": "BillingAccountOperations" + } +} \ No newline at end of file diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py index e746855a5aced..ae0fa246a91b5 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py @@ -16,29 +16,30 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import SubscriptionClientConfiguration -from .operations import SubscriptionsOperations -from .operations import TenantsOperations from .operations import SubscriptionOperations from .operations import Operations from .operations import AliasOperations +from .operations import SubscriptionPolicyOperations +from .operations import BillingAccountOperations from . import models class SubscriptionClient(object): """The subscription client. - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: subscription_client.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: subscription_client.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: subscription_client.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.subscription.operations.SubscriptionOperations :ivar operations: Operations operations - :vartype operations: subscription_client.operations.Operations + :vartype operations: azure.mgmt.subscription.operations.Operations :ivar alias: AliasOperations operations - :vartype alias: subscription_client.operations.AliasOperations + :vartype alias: azure.mgmt.subscription.operations.AliasOperations + :ivar subscription_policy: SubscriptionPolicyOperations operations + :vartype subscription_policy: azure.mgmt.subscription.operations.SubscriptionPolicyOperations + :ivar billing_account: BillingAccountOperations operations + :vartype billing_account: azure.mgmt.subscription.operations.BillingAccountOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param str base_url: Service URL @@ -62,16 +63,31 @@ def __init__( self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) self.subscription = SubscriptionOperations( self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( self._client, self._config, self._serialize, self._deserialize) + self.subscription_policy = SubscriptionPolicyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_account = BillingAccountOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response def close(self): # type: () -> None diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_configuration.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_configuration.py index b668b631b6a7b..2e6b5bb3e1757 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_configuration.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_configuration.py @@ -12,11 +12,12 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from .._version import VERSION + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" class SubscriptionClientConfiguration(Configuration): """Configuration for SubscriptionClient. @@ -38,6 +39,7 @@ def __init__( super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-subscription/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py index a60e85d09a741..554abcaaeeeb1 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_subscription_client.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -16,27 +17,27 @@ from azure.core.credentials_async import AsyncTokenCredential from ._configuration import SubscriptionClientConfiguration -from .operations import SubscriptionsOperations -from .operations import TenantsOperations from .operations import SubscriptionOperations from .operations import Operations from .operations import AliasOperations +from .operations import SubscriptionPolicyOperations +from .operations import BillingAccountOperations from .. import models class SubscriptionClient(object): """The subscription client. - :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: subscription_client.aio.operations.SubscriptionsOperations - :ivar tenants: TenantsOperations operations - :vartype tenants: subscription_client.aio.operations.TenantsOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: subscription_client.aio.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.subscription.aio.operations.SubscriptionOperations :ivar operations: Operations operations - :vartype operations: subscription_client.aio.operations.Operations + :vartype operations: azure.mgmt.subscription.aio.operations.Operations :ivar alias: AliasOperations operations - :vartype alias: subscription_client.aio.operations.AliasOperations + :vartype alias: azure.mgmt.subscription.aio.operations.AliasOperations + :ivar subscription_policy: SubscriptionPolicyOperations operations + :vartype subscription_policy: azure.mgmt.subscription.aio.operations.SubscriptionPolicyOperations + :ivar billing_account: BillingAccountOperations operations + :vartype billing_account: azure.mgmt.subscription.aio.operations.BillingAccountOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param str base_url: Service URL @@ -59,16 +60,30 @@ def __init__( self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) self.subscription = SubscriptionOperations( self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) self.alias = AliasOperations( self._client, self._config, self._serialize, self._deserialize) + self.subscription_policy = SubscriptionPolicyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.billing_account = BillingAccountOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response async def close(self) -> None: await self._client.close() diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py index 4831f8016e904..524c3eb800b82 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py @@ -6,16 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations from ._operations import Operations from ._alias_operations import AliasOperations +from ._subscription_policy_operations import SubscriptionPolicyOperations +from ._billing_account_operations import BillingAccountOperations __all__ = [ - 'SubscriptionsOperations', - 'TenantsOperations', 'SubscriptionOperations', 'Operations', 'AliasOperations', + 'SubscriptionPolicyOperations', + 'BillingAccountOperations', ] diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py index 17d132ddb2134..6243d1997b578 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_alias_operations.py @@ -15,7 +15,7 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -27,14 +27,14 @@ class AliasOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def _create_initial( self, alias_name: str, - body: "models.PutAliasRequest", - **kwargs - ) -> "models.PutAliasResponse": - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + body: "_models.PutAliasRequest", + **kwargs: Any + ) -> "_models.SubscriptionAliasResponse": + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -82,14 +82,14 @@ async def _create_initial( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -100,27 +100,29 @@ async def _create_initial( async def begin_create( self, alias_name: str, - body: "models.PutAliasRequest", - **kwargs - ) -> AsyncLROPoller["models.PutAliasResponse"]: + body: "_models.PutAliasRequest", + **kwargs: Any + ) -> AsyncLROPoller["_models.SubscriptionAliasResponse"]: """Create Alias Subscription. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :param body: - :type body: ~subscription_client.models.PutAliasRequest + :type body: ~azure.mgmt.subscription.models.PutAliasRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PutAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~subscription_client.models.PutAliasResponse] + :return: An instance of AsyncLROPoller that returns either SubscriptionAliasResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -138,13 +140,17 @@ async def begin_create( kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -161,23 +167,25 @@ def get_long_running_output(pipeline_response): async def get( self, alias_name: str, - **kwargs - ) -> "models.PutAliasResponse": + **kwargs: Any + ) -> "_models.SubscriptionAliasResponse": """Get Alias Subscription. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PutAliasResponse, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasResponse + :return: SubscriptionAliasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -201,10 +209,10 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -215,11 +223,13 @@ async def get( async def delete( self, alias_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete Alias. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -231,7 +241,7 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -255,7 +265,7 @@ async def delete( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -265,21 +275,21 @@ async def delete( async def list( self, - **kwargs - ) -> "models.PutAliasListResult": - """Get Alias Subscription. + **kwargs: Any + ) -> "_models.SubscriptionAliasListResult": + """List Alias Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: PutAliasListResult, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasListResult + :return: SubscriptionAliasListResult, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -299,10 +309,10 @@ async def list( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PutAliasListResult', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasListResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py new file mode 100644 index 0000000000000..f9ec52a660c2a --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_billing_account_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BillingAccountOperations: + """BillingAccountOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.subscription.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_policy( + self, + billing_account_id: str, + **kwargs: Any + ) -> "_models.BillingAccountPoliciesResponse": + """Get Billing Account Policy. + + :param billing_account_id: Billing Account Id. + :type billing_account_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingAccountPoliciesResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccountPoliciesResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + accept = "application/json" + + # Construct URL + url = self.get_policy.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingAccountPoliciesResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_policy.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py index 828c5e9776bd4..fb8fc76380c45 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_operations.py @@ -5,15 +5,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -25,14 +26,14 @@ class Operations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -40,49 +41,65 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def list( + def list( self, - **kwargs - ) -> "models.OperationListResult": + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available Microsoft.Subscription API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) - :rtype: ~subscription_client.models.OperationListResult + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + 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 = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py index dc02683d939fb..dd7d51e131f38 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_operations.py @@ -5,15 +5,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -25,14 +27,14 @@ class SubscriptionOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -43,23 +45,23 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def cancel( self, subscription_id: str, - **kwargs - ) -> "models.CanceledSubscriptionId": + **kwargs: Any + ) -> "_models.CanceledSubscriptionId": """The operation to cancel a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CanceledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.CanceledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CanceledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -83,7 +85,7 @@ async def cancel( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) @@ -97,26 +99,26 @@ async def cancel( async def rename( self, subscription_id: str, - body: "models.SubscriptionName", - **kwargs - ) -> "models.RenamedSubscriptionId": + body: "_models.SubscriptionName", + **kwargs: Any + ) -> "_models.RenamedSubscriptionId": """The operation to rename a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :param body: Subscription Name. - :type body: ~subscription_client.models.SubscriptionName + :type body: ~azure.mgmt.subscription.models.SubscriptionName :keyword callable cls: A custom type or function that will be passed the direct response :return: RenamedSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.RenamedSubscriptionId + :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.RenamedSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -145,7 +147,7 @@ async def rename( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) @@ -159,23 +161,23 @@ async def rename( async def enable( self, subscription_id: str, - **kwargs - ) -> "models.EnabledSubscriptionId": + **kwargs: Any + ) -> "_models.EnabledSubscriptionId": """The operation to enable a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EnabledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.EnabledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.EnabledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -199,7 +201,7 @@ async def enable( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) @@ -209,3 +211,171 @@ async def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + + async def _accept_ownership_initial( + self, + subscription_id: str, + body: "_models.AcceptOwnershipRequest", + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._accept_ownership_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'AcceptOwnershipRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _accept_ownership_initial.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership'} # type: ignore + + async def begin_accept_ownership( + self, + subscription_id: str, + body: "_models.AcceptOwnershipRequest", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Accept subscription ownership. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param body: + :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._accept_ownership_initial( + subscription_id=subscription_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_accept_ownership.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership'} # type: ignore + + async def accept_ownership_status( + self, + subscription_id: str, + **kwargs: Any + ) -> "_models.AcceptOwnershipStatusResponse": + """Accept subscription ownership status. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AcceptOwnershipStatusResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.AcceptOwnershipStatusResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcceptOwnershipStatusResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + accept = "application/json" + + # Construct URL + url = self.accept_ownership_status.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AcceptOwnershipStatusResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + accept_ownership_status.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py similarity index 52% rename from sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py rename to sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py index b168ea30639e7..a7ab886319714 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py @@ -14,26 +14,26 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SubscriptionsOperations: - """SubscriptionsOperations async operations. +class SubscriptionPolicyOperations: + """SubscriptionPolicyOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,106 +41,82 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list_locations( + async def add_update_policy_for_tenant( self, - subscription_id: str, - **kwargs - ) -> AsyncIterable["models.LocationListResult"]: - """Gets all available geo-locations. + body: "_models.PutTenantPolicyRequestProperties", + **kwargs: Any + ) -> "_models.GetTenantPolicyResponse": + """Create or Update Subscription tenant policy for user's tenant. - 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 + :param body: + :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.LocationListResult] + :return: GetTenantPolicyResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-01" + content_type = kwargs.pop("content_type", "application/json") 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') + # Construct URL + url = self.add_update_policy_for_tenant.metadata['url'] # type: ignore - 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 + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) + # 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') - async def get_next(next_link=None): - request = prepare_request(next_link) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PutTenantPolicyRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - 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('GetTenantPolicyResponse', pipeline_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) - return AsyncItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + return deserialized + add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore - async def get( + async def get_policy_for_tenant( self, - subscription_id: str, - **kwargs - ) -> "models.Subscription": - """Gets details about a specified subscription. + **kwargs: Any + ) -> "_models.GetTenantPolicyResponse": + """Get the subscription tenant policy for the user's tenant. - :param subscription_id: The ID of the target subscription. - :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~subscription_client.models.Subscription + :return: GetTenantPolicyResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-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) + url = self.get_policy_for_tenant.metadata['url'] # type: ignore # Construct parameters query_parameters = {} # type: Dict[str, Any] @@ -156,33 +132,34 @@ async def get( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore - def list( + def list_policy_for_tenant( self, - **kwargs - ) -> AsyncIterable["models.SubscriptionListResult"]: - """Gets all subscriptions for a tenant. + **kwargs: Any + ) -> AsyncIterable["_models.GetTenantPolicyListResponse"]: + """Get the subscription tenant policy for the user's tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.SubscriptionListResult] + :return: An iterator like instance of either GetTenantPolicyListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-01" accept = "application/json" def prepare_request(next_link=None): @@ -192,7 +169,7 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] # type: ignore + url = self.list_policy_for_tenant.metadata['url'] # type: ignore # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') @@ -205,7 +182,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize('GetTenantPolicyListResponse', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -218,12 +195,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions'} # type: ignore + list_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py deleted file mode 100644 index 9dca210799dcb..0000000000000 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs - ) -> AsyncIterable["models.TenantListResult"]: - """Gets the tenants for your account. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~subscription_client.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py index aa5146a991e6c..323f5910c6859 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py @@ -7,81 +7,96 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import AcceptOwnershipRequest + from ._models_py3 import AcceptOwnershipRequestProperties + from ._models_py3 import AcceptOwnershipStatusResponse + from ._models_py3 import BillingAccountPoliciesResponse + from ._models_py3 import BillingAccountPoliciesResponseProperties from ._models_py3 import CanceledSubscriptionId from ._models_py3 import EnabledSubscriptionId from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseBody - from ._models_py3 import Location - from ._models_py3 import LocationListResult + from ._models_py3 import GetTenantPolicyListResponse + from ._models_py3 import GetTenantPolicyResponse from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult - from ._models_py3 import PutAliasListResult from ._models_py3 import PutAliasRequest + from ._models_py3 import PutAliasRequestAdditionalProperties from ._models_py3 import PutAliasRequestProperties - from ._models_py3 import PutAliasResponse - from ._models_py3 import PutAliasResponseProperties + from ._models_py3 import PutTenantPolicyRequestProperties from ._models_py3 import RenamedSubscriptionId - from ._models_py3 import Subscription - from ._models_py3 import SubscriptionListResult + from ._models_py3 import ServiceTenantResponse + from ._models_py3 import SubscriptionAliasListResult + from ._models_py3 import SubscriptionAliasResponse + from ._models_py3 import SubscriptionAliasResponseProperties from ._models_py3 import SubscriptionName - from ._models_py3 import SubscriptionPolicies - from ._models_py3 import TenantIdDescription - from ._models_py3 import TenantListResult + from ._models_py3 import SystemData + from ._models_py3 import TenantPolicy except (SyntaxError, ImportError): + from ._models import AcceptOwnershipRequest # type: ignore + from ._models import AcceptOwnershipRequestProperties # type: ignore + from ._models import AcceptOwnershipStatusResponse # type: ignore + from ._models import BillingAccountPoliciesResponse # type: ignore + from ._models import BillingAccountPoliciesResponseProperties # type: ignore from ._models import CanceledSubscriptionId # type: ignore from ._models import EnabledSubscriptionId # type: ignore from ._models import ErrorResponse # type: ignore from ._models import ErrorResponseBody # type: ignore - from ._models import Location # type: ignore - from ._models import LocationListResult # type: ignore + from ._models import GetTenantPolicyListResponse # type: ignore + from ._models import GetTenantPolicyResponse # type: ignore from ._models import Operation # type: ignore from ._models import OperationDisplay # type: ignore from ._models import OperationListResult # type: ignore - from ._models import PutAliasListResult # type: ignore from ._models import PutAliasRequest # type: ignore + from ._models import PutAliasRequestAdditionalProperties # type: ignore from ._models import PutAliasRequestProperties # type: ignore - from ._models import PutAliasResponse # type: ignore - from ._models import PutAliasResponseProperties # type: ignore + from ._models import PutTenantPolicyRequestProperties # type: ignore from ._models import RenamedSubscriptionId # type: ignore - from ._models import Subscription # type: ignore - from ._models import SubscriptionListResult # type: ignore + from ._models import ServiceTenantResponse # type: ignore + from ._models import SubscriptionAliasListResult # type: ignore + from ._models import SubscriptionAliasResponse # type: ignore + from ._models import SubscriptionAliasResponseProperties # type: ignore from ._models import SubscriptionName # type: ignore - from ._models import SubscriptionPolicies # type: ignore - from ._models import TenantIdDescription # type: ignore - from ._models import TenantListResult # type: ignore + from ._models import SystemData # type: ignore + from ._models import TenantPolicy # type: ignore from ._subscription_client_enums import ( + AcceptOwnership, + CreatedByType, ProvisioningState, - SpendingLimit, - SubscriptionState, Workload, ) __all__ = [ + 'AcceptOwnershipRequest', + 'AcceptOwnershipRequestProperties', + 'AcceptOwnershipStatusResponse', + 'BillingAccountPoliciesResponse', + 'BillingAccountPoliciesResponseProperties', 'CanceledSubscriptionId', 'EnabledSubscriptionId', 'ErrorResponse', 'ErrorResponseBody', - 'Location', - 'LocationListResult', + 'GetTenantPolicyListResponse', + 'GetTenantPolicyResponse', 'Operation', 'OperationDisplay', 'OperationListResult', - 'PutAliasListResult', 'PutAliasRequest', + 'PutAliasRequestAdditionalProperties', 'PutAliasRequestProperties', - 'PutAliasResponse', - 'PutAliasResponseProperties', + 'PutTenantPolicyRequestProperties', 'RenamedSubscriptionId', - 'Subscription', - 'SubscriptionListResult', + 'ServiceTenantResponse', + 'SubscriptionAliasListResult', + 'SubscriptionAliasResponse', + 'SubscriptionAliasResponseProperties', 'SubscriptionName', - 'SubscriptionPolicies', - 'TenantIdDescription', - 'TenantListResult', + 'SystemData', + 'TenantPolicy', + 'AcceptOwnership', + 'CreatedByType', 'ProvisioningState', - 'SpendingLimit', - 'SubscriptionState', 'Workload', ] diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py index 7e2e60058b6b7..90d5a50007c73 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py @@ -10,6 +10,173 @@ import msrest.serialization +class AcceptOwnershipRequest(msrest.serialization.Model): + """The parameters required to accept subscription ownership. + + :param properties: Accept subscription ownership request properties. + :type properties: ~azure.mgmt.subscription.models.AcceptOwnershipRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AcceptOwnershipRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(AcceptOwnershipRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AcceptOwnershipRequestProperties(msrest.serialization.Model): + """Accept subscription ownership request properties. + + All required parameters must be populated in order to send to Azure. + + :param display_name: Required. The friendly name of the subscription. + :type display_name: str + :param management_group_id: Management group Id for the subscription. + :type management_group_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'display_name': {'required': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(AcceptOwnershipRequestProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.management_group_id = kwargs.get('management_group_id', None) + self.tags = kwargs.get('tags', None) + + +class AcceptOwnershipStatusResponse(msrest.serialization.Model): + """Subscription Accept Ownership Response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :ivar accept_ownership_state: The accept ownership state of the resource. Possible values + include: "Pending", "Completed", "Expired". + :vartype accept_ownership_state: str or ~azure.mgmt.subscription.models.AcceptOwnership + :ivar billing_owner: UPN of the billing owner. + :vartype billing_owner: str + :param subscription_tenant_id: Tenant Id of the subscription. + :type subscription_tenant_id: str + :param display_name: The display name of the subscription. + :type display_name: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'subscription_id': {'readonly': True}, + 'accept_ownership_state': {'readonly': True}, + 'billing_owner': {'readonly': True}, + } + + _attribute_map = { + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'accept_ownership_state': {'key': 'acceptOwnershipState', 'type': 'str'}, + 'billing_owner': {'key': 'billingOwner', 'type': 'str'}, + 'subscription_tenant_id': {'key': 'subscriptionTenantId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(AcceptOwnershipStatusResponse, self).__init__(**kwargs) + self.subscription_id = None + self.accept_ownership_state = None + self.billing_owner = None + self.subscription_tenant_id = kwargs.get('subscription_tenant_id', None) + self.display_name = kwargs.get('display_name', None) + self.tags = kwargs.get('tags', None) + + +class BillingAccountPoliciesResponse(msrest.serialization.Model): + """Billing account policies information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the policy. + :vartype id: str + :ivar name: Policy name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param properties: Billing account policies response properties. + :type properties: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponseProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BillingAccountPoliciesResponseProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccountPoliciesResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + self.system_data = None + + +class BillingAccountPoliciesResponseProperties(msrest.serialization.Model): + """Put billing account policies response properties. + + :param service_tenants: Service tenant for the billing account. + :type service_tenants: list[~azure.mgmt.subscription.models.ServiceTenantResponse] + :param allow_transfers: Determine if the transfers are allowed for the billing account. + :type allow_transfers: bool + """ + + _attribute_map = { + 'service_tenants': {'key': 'serviceTenants', 'type': '[ServiceTenantResponse]'}, + 'allow_transfers': {'key': 'allowTransfers', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingAccountPoliciesResponseProperties, self).__init__(**kwargs) + self.service_tenants = kwargs.get('service_tenants', None) + self.allow_transfers = kwargs.get('allow_transfers', None) + + class CanceledSubscriptionId(msrest.serialization.Model): """The ID of the canceled subscription. @@ -87,11 +254,17 @@ class ErrorResponseBody(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. :param error: The details of the error. - :type error: ~subscription_client.models.ErrorResponse + :type error: ~azure.mgmt.subscription.models.ErrorResponse + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str """ _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, } def __init__( @@ -100,76 +273,82 @@ def __init__( ): super(ErrorResponseBody, self).__init__(**kwargs) self.error = kwargs.get('error', None) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) -class Location(msrest.serialization.Model): - """Location information. +class GetTenantPolicyListResponse(msrest.serialization.Model): + """Tenant policy information list. 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 + :ivar value: The list of tenant policies. + :vartype value: list[~azure.mgmt.subscription.models.GetTenantPolicyResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'latitude': {'readonly': True}, - 'longitude': {'readonly': True}, + 'value': {'readonly': True}, + 'next_link': {'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'}, + 'value': {'key': 'value', 'type': '[GetTenantPolicyResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): - super(Location, self).__init__(**kwargs) - self.id = None - self.subscription_id = None - self.name = None - self.display_name = None - self.latitude = None - self.longitude = None + super(GetTenantPolicyListResponse, self).__init__(**kwargs) + self.value = None + self.next_link = None -class LocationListResult(msrest.serialization.Model): - """Location list operation response. +class GetTenantPolicyResponse(msrest.serialization.Model): + """Tenant policy Information. - :param value: An array of locations. - :type value: list[~subscription_client.models.Location] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Policy Id. + :vartype id: str + :ivar name: Policy name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param properties: Tenant policy properties. + :type properties: ~azure.mgmt.subscription.models.TenantPolicy + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'TenantPolicy'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): - super(LocationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) + super(GetTenantPolicyResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + self.system_data = None class Operation(msrest.serialization.Model): @@ -177,12 +356,15 @@ class Operation(msrest.serialization.Model): :param name: Operation name: {provider}/{resource}/{operation}. :type name: str + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool :param display: The object that represents the operation. - :type display: ~subscription_client.models.OperationDisplay + :type display: ~azure.mgmt.subscription.models.OperationDisplay """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, } @@ -192,6 +374,7 @@ def __init__( ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) + self.is_data_action = kwargs.get('is_data_action', None) self.display = kwargs.get('display', None) @@ -204,12 +387,15 @@ class OperationDisplay(msrest.serialization.Model): :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str + :param description: Localized friendly description for 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__( @@ -220,13 +406,14 @@ def __init__( 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 operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~subscription_client.models.Operation] + :type value: list[~azure.mgmt.subscription.models.Operation] :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -245,59 +432,54 @@ def __init__( self.next_link = kwargs.get('next_link', None) -class PutAliasListResult(msrest.serialization.Model): - """The list of aliases. - - Variables are only populated by the server, and will be ignored when sending a request. +class PutAliasRequest(msrest.serialization.Model): + """The parameters required to create a new subscription. - :ivar value: The list of alias. - :vartype value: list[~subscription_client.models.PutAliasResponse] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str + :param properties: Put alias request properties. + :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - _attribute_map = { - 'value': {'key': 'value', 'type': '[PutAliasResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } def __init__( self, **kwargs ): - super(PutAliasListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - + super(PutAliasRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) -class PutAliasRequest(msrest.serialization.Model): - """The parameters required to create a new subscription. - All required parameters must be populated in order to send to Azure. +class PutAliasRequestAdditionalProperties(msrest.serialization.Model): + """Put subscription additional properties. - :param properties: Required. Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :param management_group_id: Management group Id for the subscription. + :type management_group_id: str + :param subscription_tenant_id: Tenant Id of the subscription. + :type subscription_tenant_id: str + :param subscription_owner_id: Owner Id of the subscription. + :type subscription_owner_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] """ - _validation = { - 'properties': {'required': True}, - } - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'subscription_tenant_id': {'key': 'subscriptionTenantId', 'type': 'str'}, + 'subscription_owner_id': {'key': 'subscriptionOwnerId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, **kwargs ): - super(PutAliasRequest, self).__init__(**kwargs) - self.properties = kwargs['properties'] + super(PutAliasRequestAdditionalProperties, self).__init__(**kwargs) + self.management_group_id = kwargs.get('management_group_id', None) + self.subscription_tenant_id = kwargs.get('subscription_tenant_id', None) + self.subscription_owner_id = kwargs.get('subscription_owner_id', None) + self.tags = kwargs.get('tags', None) class PutAliasRequestProperties(msrest.serialization.Model): @@ -307,14 +489,22 @@ class PutAliasRequestProperties(msrest.serialization.Model): :type display_name: str :param workload: The workload type of the subscription. It can be either Production or DevTest. Possible values include: "Production", "DevTest". - :type workload: str or ~subscription_client.models.Workload - :param billing_scope: Determines whether subscription is fieldLed, partnerLed or LegacyEA. + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param billing_scope: Billing scope of the subscription. + For CustomerLed and FieldLed - + /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + For Legacy EA - + /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}. :type billing_scope: str :param subscription_id: This parameter can be used to create alias for existing subscription Id. :type subscription_id: str - :param reseller_id: Reseller ID, basically MPN Id. + :param reseller_id: Reseller Id. :type reseller_id: str + :param additional_properties: Put alias request additional properties. + :type additional_properties: + ~azure.mgmt.subscription.models.PutAliasRequestAdditionalProperties """ _attribute_map = { @@ -323,6 +513,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): 'billing_scope': {'key': 'billingScope', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'PutAliasRequestAdditionalProperties'}, } def __init__( @@ -335,181 +526,234 @@ def __init__( self.billing_scope = kwargs.get('billing_scope', None) self.subscription_id = kwargs.get('subscription_id', None) self.reseller_id = kwargs.get('reseller_id', None) + self.additional_properties = kwargs.get('additional_properties', None) -class PutAliasResponse(msrest.serialization.Model): - """Subscription Information with the alias. - - Variables are only populated by the server, and will be ignored when sending a request. +class PutTenantPolicyRequestProperties(msrest.serialization.Model): + """Put tenant policy request properties. - :ivar id: Fully qualified ID for the alias resource. - :vartype id: str - :ivar name: Alias ID. - :vartype name: str - :ivar type: Resource type, Microsoft.Subscription/aliases. - :vartype type: str - :param properties: Put Alias response properties. - :type properties: ~subscription_client.models.PutAliasResponseProperties + :param block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :type block_subscriptions_leaving_tenant: bool + :param block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :type block_subscriptions_into_tenant: bool + :param exempted_principals: List of user objectIds that are exempted from the set subscription + tenant policies for the user's tenant. + :type exempted_principals: list[str] """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PutAliasResponseProperties'}, + 'block_subscriptions_leaving_tenant': {'key': 'blockSubscriptionsLeavingTenant', 'type': 'bool'}, + 'block_subscriptions_into_tenant': {'key': 'blockSubscriptionsIntoTenant', 'type': 'bool'}, + 'exempted_principals': {'key': 'exemptedPrincipals', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(PutAliasResponse, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs.get('properties', None) + super(PutTenantPolicyRequestProperties, self).__init__(**kwargs) + self.block_subscriptions_leaving_tenant = kwargs.get('block_subscriptions_leaving_tenant', None) + self.block_subscriptions_into_tenant = kwargs.get('block_subscriptions_into_tenant', None) + self.exempted_principals = kwargs.get('exempted_principals', None) -class PutAliasResponseProperties(msrest.serialization.Model): - """Put subscription creation result properties. +class RenamedSubscriptionId(msrest.serialization.Model): + """The ID of the subscriptions that is being renamed. Variables are only populated by the server, and will be ignored when sending a request. - :ivar subscription_id: Newly created subscription Id. - :vartype subscription_id: str - :param provisioning_state: The provisioning state of the resource. Possible values include: - "Accepted", "Succeeded", "Failed". - :type provisioning_state: str or ~subscription_client.models.ProvisioningState + :ivar value: The ID of the subscriptions that is being renamed. + :vartype value: str """ _validation = { - 'subscription_id': {'readonly': True}, + 'value': {'readonly': True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, } def __init__( self, **kwargs ): - super(PutAliasResponseProperties, self).__init__(**kwargs) - self.subscription_id = None - self.provisioning_state = kwargs.get('provisioning_state', None) + super(RenamedSubscriptionId, self).__init__(**kwargs) + self.value = None -class RenamedSubscriptionId(msrest.serialization.Model): - """The ID of the subscriptions that is being renamed. +class ServiceTenantResponse(msrest.serialization.Model): + """Billing account service tenant. + + :param tenant_id: Service tenant id. + :type tenant_id: str + :param tenant_name: Service tenant name. + :type tenant_name: str + """ + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_name': {'key': 'tenantName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceTenantResponse, self).__init__(**kwargs) + self.tenant_id = kwargs.get('tenant_id', None) + self.tenant_name = kwargs.get('tenant_name', None) + + +class SubscriptionAliasListResult(msrest.serialization.Model): + """The list of aliases. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being renamed. - :vartype value: str + :ivar value: The list of alias. + :vartype value: list[~azure.mgmt.subscription.models.SubscriptionAliasResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str """ _validation = { 'value': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[SubscriptionAliasResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): - super(RenamedSubscriptionId, self).__init__(**kwargs) + super(SubscriptionAliasListResult, self).__init__(**kwargs) self.value = None + self.next_link = None -class Subscription(msrest.serialization.Model): - """Subscription information. +class SubscriptionAliasResponse(msrest.serialization.Model): + """Subscription Information with the alias. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The fully qualified ID for the subscription. For example, - /subscriptions/00000000-0000-0000-0000-000000000000. + :ivar id: Fully qualified ID for the alias resource. :vartype id: str - :ivar subscription_id: The subscription ID. - :vartype subscription_id: str - :ivar display_name: The subscription display name. - :vartype display_name: str - :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". - :vartype state: str or ~subscription_client.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: ~subscription_client.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or - more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, - RoleBased'. - :type authorization_source: str + :ivar name: Alias ID. + :vartype name: str + :ivar type: Resource type, Microsoft.Subscription/aliases. + :vartype type: str + :param properties: Subscription Alias response properties. + :type properties: ~azure.mgmt.subscription.models.SubscriptionAliasResponseProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData """ _validation = { 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'state': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'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'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SubscriptionAliasResponseProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): - super(Subscription, self).__init__(**kwargs) + super(SubscriptionAliasResponse, 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) + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + self.system_data = None -class SubscriptionListResult(msrest.serialization.Model): - """Subscription list operation response. +class SubscriptionAliasResponseProperties(msrest.serialization.Model): + """Put subscription creation result properties. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of subscriptions. - :type value: list[~subscription_client.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :param display_name: The display name of the subscription. + :type display_name: str + :param provisioning_state: The provisioning state of the resource. Possible values include: + "Accepted", "Succeeded", "Failed". + :type provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState + :ivar accept_ownership_url: Url to accept ownership of the subscription. + :vartype accept_ownership_url: str + :ivar accept_ownership_state: The accept ownership state of the resource. Possible values + include: "Pending", "Completed", "Expired". + :vartype accept_ownership_state: str or ~azure.mgmt.subscription.models.AcceptOwnership + :param billing_scope: Billing scope of the subscription. + For CustomerLed and FieldLed - + /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + For Legacy EA - + /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}. + :type billing_scope: str + :param workload: The workload type of the subscription. It can be either Production or DevTest. + Possible values include: "Production", "DevTest". + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param reseller_id: Reseller Id. + :type reseller_id: str + :param subscription_owner_id: Owner Id of the subscription. + :type subscription_owner_id: str + :param management_group_id: The Management Group Id. + :type management_group_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] """ _validation = { - 'next_link': {'required': True}, + 'subscription_id': {'readonly': True}, + 'accept_ownership_url': {'readonly': True}, + 'accept_ownership_state': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'accept_ownership_url': {'key': 'acceptOwnershipUrl', 'type': 'str'}, + 'accept_ownership_state': {'key': 'acceptOwnershipState', 'type': 'str'}, + 'billing_scope': {'key': 'billingScope', 'type': 'str'}, + 'workload': {'key': 'workload', 'type': 'str'}, + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'subscription_owner_id': {'key': 'subscriptionOwnerId', 'type': 'str'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, **kwargs ): - super(SubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs['next_link'] + super(SubscriptionAliasResponseProperties, self).__init__(**kwargs) + self.subscription_id = None + self.display_name = kwargs.get('display_name', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.accept_ownership_url = None + self.accept_ownership_state = None + self.billing_scope = kwargs.get('billing_scope', None) + self.workload = kwargs.get('workload', None) + self.reseller_id = kwargs.get('reseller_id', None) + self.subscription_owner_id = kwargs.get('subscription_owner_id', None) + self.management_group_id = kwargs.get('management_group_id', None) + self.tags = kwargs.get('tags', None) class SubscriptionName(msrest.serialization.Model): @@ -531,99 +775,82 @@ def __init__( self.subscription_name = kwargs.get('subscription_name', None) -class SubscriptionPolicies(msrest.serialization.Model): - """Subscription policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location_placement_id: The subscription location placement ID. The ID indicates which - regions are visible for a subscription. For example, a subscription with a location placement - Id of Public_2014-09-01 has access to Azure public regions. - :vartype location_placement_id: str - :ivar quota_id: The subscription quota ID. - :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", - "CurrentPeriodOff". - :vartype spending_limit: str or ~subscription_client.models.SpendingLimit +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime """ - _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'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(SubscriptionPolicies, self).__init__(**kwargs) - self.location_placement_id = None - self.quota_id = None - self.spending_limit = None + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) -class TenantIdDescription(msrest.serialization.Model): - """Tenant Id information. +class TenantPolicy(msrest.serialization.Model): + """Tenant policy. 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 policy_id: Policy Id. + :vartype policy_id: str + :param block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :type block_subscriptions_leaving_tenant: bool + :param block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :type block_subscriptions_into_tenant: bool + :param exempted_principals: List of user objectIds that are exempted from the set subscription + tenant policies for the user's tenant. + :type exempted_principals: list[str] """ _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + 'policy_id': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'policy_id': {'key': 'policyId', 'type': 'str'}, + 'block_subscriptions_leaving_tenant': {'key': 'blockSubscriptionsLeavingTenant', 'type': 'bool'}, + 'block_subscriptions_into_tenant': {'key': 'blockSubscriptionsIntoTenant', 'type': 'bool'}, + 'exempted_principals': {'key': 'exemptedPrincipals', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - - -class TenantListResult(msrest.serialization.Model): - """Tenant Ids information. - - All required parameters must be populated in order to send to Azure. - - :param value: An array of tenants. - :type value: list[~subscription_client.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str - """ - - _validation = { - 'next_link': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs['next_link'] + super(TenantPolicy, self).__init__(**kwargs) + self.policy_id = None + self.block_subscriptions_leaving_tenant = kwargs.get('block_subscriptions_leaving_tenant', None) + self.block_subscriptions_into_tenant = kwargs.get('block_subscriptions_into_tenant', None) + self.exempted_principals = kwargs.get('exempted_principals', None) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py index 7067cd918eef8..c253155dafe0c 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py @@ -6,7 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +import datetime +from typing import Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -14,6 +15,188 @@ from ._subscription_client_enums import * +class AcceptOwnershipRequest(msrest.serialization.Model): + """The parameters required to accept subscription ownership. + + :param properties: Accept subscription ownership request properties. + :type properties: ~azure.mgmt.subscription.models.AcceptOwnershipRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AcceptOwnershipRequestProperties'}, + } + + def __init__( + self, + *, + properties: Optional["AcceptOwnershipRequestProperties"] = None, + **kwargs + ): + super(AcceptOwnershipRequest, self).__init__(**kwargs) + self.properties = properties + + +class AcceptOwnershipRequestProperties(msrest.serialization.Model): + """Accept subscription ownership request properties. + + All required parameters must be populated in order to send to Azure. + + :param display_name: Required. The friendly name of the subscription. + :type display_name: str + :param management_group_id: Management group Id for the subscription. + :type management_group_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'display_name': {'required': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + display_name: str, + management_group_id: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(AcceptOwnershipRequestProperties, self).__init__(**kwargs) + self.display_name = display_name + self.management_group_id = management_group_id + self.tags = tags + + +class AcceptOwnershipStatusResponse(msrest.serialization.Model): + """Subscription Accept Ownership Response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :ivar accept_ownership_state: The accept ownership state of the resource. Possible values + include: "Pending", "Completed", "Expired". + :vartype accept_ownership_state: str or ~azure.mgmt.subscription.models.AcceptOwnership + :ivar billing_owner: UPN of the billing owner. + :vartype billing_owner: str + :param subscription_tenant_id: Tenant Id of the subscription. + :type subscription_tenant_id: str + :param display_name: The display name of the subscription. + :type display_name: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] + """ + + _validation = { + 'subscription_id': {'readonly': True}, + 'accept_ownership_state': {'readonly': True}, + 'billing_owner': {'readonly': True}, + } + + _attribute_map = { + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'accept_ownership_state': {'key': 'acceptOwnershipState', 'type': 'str'}, + 'billing_owner': {'key': 'billingOwner', 'type': 'str'}, + 'subscription_tenant_id': {'key': 'subscriptionTenantId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + subscription_tenant_id: Optional[str] = None, + display_name: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(AcceptOwnershipStatusResponse, self).__init__(**kwargs) + self.subscription_id = None + self.accept_ownership_state = None + self.billing_owner = None + self.subscription_tenant_id = subscription_tenant_id + self.display_name = display_name + self.tags = tags + + +class BillingAccountPoliciesResponse(msrest.serialization.Model): + """Billing account policies information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the policy. + :vartype id: str + :ivar name: Policy name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param properties: Billing account policies response properties. + :type properties: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponseProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BillingAccountPoliciesResponseProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + properties: Optional["BillingAccountPoliciesResponseProperties"] = None, + **kwargs + ): + super(BillingAccountPoliciesResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + self.system_data = None + + +class BillingAccountPoliciesResponseProperties(msrest.serialization.Model): + """Put billing account policies response properties. + + :param service_tenants: Service tenant for the billing account. + :type service_tenants: list[~azure.mgmt.subscription.models.ServiceTenantResponse] + :param allow_transfers: Determine if the transfers are allowed for the billing account. + :type allow_transfers: bool + """ + + _attribute_map = { + 'service_tenants': {'key': 'serviceTenants', 'type': '[ServiceTenantResponse]'}, + 'allow_transfers': {'key': 'allowTransfers', 'type': 'bool'}, + } + + def __init__( + self, + *, + service_tenants: Optional[List["ServiceTenantResponse"]] = None, + allow_transfers: Optional[bool] = None, + **kwargs + ): + super(BillingAccountPoliciesResponseProperties, self).__init__(**kwargs) + self.service_tenants = service_tenants + self.allow_transfers = allow_transfers + + class CanceledSubscriptionId(msrest.serialization.Model): """The ID of the canceled subscription. @@ -94,93 +277,107 @@ class ErrorResponseBody(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. :param error: The details of the error. - :type error: ~subscription_client.models.ErrorResponse + :type error: ~azure.mgmt.subscription.models.ErrorResponse + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str """ _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, } def __init__( self, *, error: Optional["ErrorResponse"] = None, + code: Optional[str] = None, + message: Optional[str] = None, **kwargs ): super(ErrorResponseBody, self).__init__(**kwargs) self.error = error + self.code = code + self.message = message -class Location(msrest.serialization.Model): - """Location information. +class GetTenantPolicyListResponse(msrest.serialization.Model): + """Tenant policy information list. 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 + :ivar value: The list of tenant policies. + :vartype value: list[~azure.mgmt.subscription.models.GetTenantPolicyResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str """ _validation = { - 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'latitude': {'readonly': True}, - 'longitude': {'readonly': True}, + 'value': {'readonly': True}, + 'next_link': {'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'}, + 'value': {'key': 'value', 'type': '[GetTenantPolicyResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): - super(Location, self).__init__(**kwargs) - self.id = None - self.subscription_id = None - self.name = None - self.display_name = None - self.latitude = None - self.longitude = None + super(GetTenantPolicyListResponse, self).__init__(**kwargs) + self.value = None + self.next_link = None -class LocationListResult(msrest.serialization.Model): - """Location list operation response. +class GetTenantPolicyResponse(msrest.serialization.Model): + """Tenant policy Information. + + Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of locations. - :type value: list[~subscription_client.models.Location] + :ivar id: Policy Id. + :vartype id: str + :ivar name: Policy name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param properties: Tenant policy properties. + :type properties: ~azure.mgmt.subscription.models.TenantPolicy + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[Location]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'TenantPolicy'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, *, - value: Optional[List["Location"]] = None, + properties: Optional["TenantPolicy"] = None, **kwargs ): - super(LocationListResult, self).__init__(**kwargs) - self.value = value + super(GetTenantPolicyResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + self.system_data = None class Operation(msrest.serialization.Model): @@ -188,12 +385,15 @@ class Operation(msrest.serialization.Model): :param name: Operation name: {provider}/{resource}/{operation}. :type name: str + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool :param display: The object that represents the operation. - :type display: ~subscription_client.models.OperationDisplay + :type display: ~azure.mgmt.subscription.models.OperationDisplay """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, } @@ -201,11 +401,13 @@ def __init__( self, *, name: Optional[str] = None, + is_data_action: Optional[bool] = None, display: Optional["OperationDisplay"] = None, **kwargs ): super(Operation, self).__init__(**kwargs) self.name = name + self.is_data_action = is_data_action self.display = display @@ -218,12 +420,15 @@ class OperationDisplay(msrest.serialization.Model): :type resource: str :param operation: Operation type: Read, write, delete, etc. :type operation: str + :param description: Localized friendly description for 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__( @@ -232,19 +437,21 @@ def __init__( 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 operations. It contains a list of operations and a URL link to get the next set of results. :param value: List of operations. - :type value: list[~subscription_client.models.Operation] + :type value: list[~azure.mgmt.subscription.models.Operation] :param next_link: URL to get the next set of operation list results if there are any. :type next_link: str """ @@ -266,61 +473,61 @@ def __init__( self.next_link = next_link -class PutAliasListResult(msrest.serialization.Model): - """The list of aliases. - - Variables are only populated by the server, and will be ignored when sending a request. +class PutAliasRequest(msrest.serialization.Model): + """The parameters required to create a new subscription. - :ivar value: The list of alias. - :vartype value: list[~subscription_client.models.PutAliasResponse] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str + :param properties: Put alias request properties. + :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - _attribute_map = { - 'value': {'key': 'value', 'type': '[PutAliasResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } def __init__( self, + *, + properties: Optional["PutAliasRequestProperties"] = None, **kwargs ): - super(PutAliasListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - + super(PutAliasRequest, self).__init__(**kwargs) + self.properties = properties -class PutAliasRequest(msrest.serialization.Model): - """The parameters required to create a new subscription. - All required parameters must be populated in order to send to Azure. +class PutAliasRequestAdditionalProperties(msrest.serialization.Model): + """Put subscription additional properties. - :param properties: Required. Put alias request properties. - :type properties: ~subscription_client.models.PutAliasRequestProperties + :param management_group_id: Management group Id for the subscription. + :type management_group_id: str + :param subscription_tenant_id: Tenant Id of the subscription. + :type subscription_tenant_id: str + :param subscription_owner_id: Owner Id of the subscription. + :type subscription_owner_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] """ - _validation = { - 'properties': {'required': True}, - } - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'subscription_tenant_id': {'key': 'subscriptionTenantId', 'type': 'str'}, + 'subscription_owner_id': {'key': 'subscriptionOwnerId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, *, - properties: "PutAliasRequestProperties", + management_group_id: Optional[str] = None, + subscription_tenant_id: Optional[str] = None, + subscription_owner_id: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, **kwargs ): - super(PutAliasRequest, self).__init__(**kwargs) - self.properties = properties + super(PutAliasRequestAdditionalProperties, self).__init__(**kwargs) + self.management_group_id = management_group_id + self.subscription_tenant_id = subscription_tenant_id + self.subscription_owner_id = subscription_owner_id + self.tags = tags class PutAliasRequestProperties(msrest.serialization.Model): @@ -330,14 +537,22 @@ class PutAliasRequestProperties(msrest.serialization.Model): :type display_name: str :param workload: The workload type of the subscription. It can be either Production or DevTest. Possible values include: "Production", "DevTest". - :type workload: str or ~subscription_client.models.Workload - :param billing_scope: Determines whether subscription is fieldLed, partnerLed or LegacyEA. + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param billing_scope: Billing scope of the subscription. + For CustomerLed and FieldLed - + /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + For Legacy EA - + /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}. :type billing_scope: str :param subscription_id: This parameter can be used to create alias for existing subscription Id. :type subscription_id: str - :param reseller_id: Reseller ID, basically MPN Id. + :param reseller_id: Reseller Id. :type reseller_id: str + :param additional_properties: Put alias request additional properties. + :type additional_properties: + ~azure.mgmt.subscription.models.PutAliasRequestAdditionalProperties """ _attribute_map = { @@ -346,6 +561,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): 'billing_scope': {'key': 'billingScope', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'additional_properties': {'key': 'additionalProperties', 'type': 'PutAliasRequestAdditionalProperties'}, } def __init__( @@ -356,6 +572,7 @@ def __init__( billing_scope: Optional[str] = None, subscription_id: Optional[str] = None, reseller_id: Optional[str] = None, + additional_properties: Optional["PutAliasRequestAdditionalProperties"] = None, **kwargs ): super(PutAliasRequestProperties, self).__init__(**kwargs) @@ -364,191 +581,252 @@ def __init__( self.billing_scope = billing_scope self.subscription_id = subscription_id self.reseller_id = reseller_id + self.additional_properties = additional_properties -class PutAliasResponse(msrest.serialization.Model): - """Subscription Information with the alias. - - Variables are only populated by the server, and will be ignored when sending a request. +class PutTenantPolicyRequestProperties(msrest.serialization.Model): + """Put tenant policy request properties. - :ivar id: Fully qualified ID for the alias resource. - :vartype id: str - :ivar name: Alias ID. - :vartype name: str - :ivar type: Resource type, Microsoft.Subscription/aliases. - :vartype type: str - :param properties: Put Alias response properties. - :type properties: ~subscription_client.models.PutAliasResponseProperties + :param block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :type block_subscriptions_leaving_tenant: bool + :param block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :type block_subscriptions_into_tenant: bool + :param exempted_principals: List of user objectIds that are exempted from the set subscription + tenant policies for the user's tenant. + :type exempted_principals: list[str] """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PutAliasResponseProperties'}, + 'block_subscriptions_leaving_tenant': {'key': 'blockSubscriptionsLeavingTenant', 'type': 'bool'}, + 'block_subscriptions_into_tenant': {'key': 'blockSubscriptionsIntoTenant', 'type': 'bool'}, + 'exempted_principals': {'key': 'exemptedPrincipals', 'type': '[str]'}, } def __init__( self, *, - properties: Optional["PutAliasResponseProperties"] = None, + block_subscriptions_leaving_tenant: Optional[bool] = None, + block_subscriptions_into_tenant: Optional[bool] = None, + exempted_principals: Optional[List[str]] = None, **kwargs ): - super(PutAliasResponse, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties + super(PutTenantPolicyRequestProperties, self).__init__(**kwargs) + self.block_subscriptions_leaving_tenant = block_subscriptions_leaving_tenant + self.block_subscriptions_into_tenant = block_subscriptions_into_tenant + self.exempted_principals = exempted_principals -class PutAliasResponseProperties(msrest.serialization.Model): - """Put subscription creation result properties. +class RenamedSubscriptionId(msrest.serialization.Model): + """The ID of the subscriptions that is being renamed. Variables are only populated by the server, and will be ignored when sending a request. - :ivar subscription_id: Newly created subscription Id. - :vartype subscription_id: str - :param provisioning_state: The provisioning state of the resource. Possible values include: - "Accepted", "Succeeded", "Failed". - :type provisioning_state: str or ~subscription_client.models.ProvisioningState + :ivar value: The ID of the subscriptions that is being renamed. + :vartype value: str """ _validation = { - 'subscription_id': {'readonly': True}, + 'value': {'readonly': True}, } _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RenamedSubscriptionId, self).__init__(**kwargs) + self.value = None + + +class ServiceTenantResponse(msrest.serialization.Model): + """Billing account service tenant. + + :param tenant_id: Service tenant id. + :type tenant_id: str + :param tenant_name: Service tenant name. + :type tenant_name: str + """ + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_name': {'key': 'tenantName', 'type': 'str'}, } def __init__( self, *, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + tenant_id: Optional[str] = None, + tenant_name: Optional[str] = None, **kwargs ): - super(PutAliasResponseProperties, self).__init__(**kwargs) - self.subscription_id = None - self.provisioning_state = provisioning_state + super(ServiceTenantResponse, self).__init__(**kwargs) + self.tenant_id = tenant_id + self.tenant_name = tenant_name -class RenamedSubscriptionId(msrest.serialization.Model): - """The ID of the subscriptions that is being renamed. +class SubscriptionAliasListResult(msrest.serialization.Model): + """The list of aliases. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The ID of the subscriptions that is being renamed. - :vartype value: str + :ivar value: The list of alias. + :vartype value: list[~azure.mgmt.subscription.models.SubscriptionAliasResponse] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str """ _validation = { 'value': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[SubscriptionAliasResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, **kwargs ): - super(RenamedSubscriptionId, self).__init__(**kwargs) + super(SubscriptionAliasListResult, self).__init__(**kwargs) self.value = None + self.next_link = None -class Subscription(msrest.serialization.Model): - """Subscription information. +class SubscriptionAliasResponse(msrest.serialization.Model): + """Subscription Information with the alias. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The fully qualified ID for the subscription. For example, - /subscriptions/00000000-0000-0000-0000-000000000000. + :ivar id: Fully qualified ID for the alias resource. :vartype id: str - :ivar subscription_id: The subscription ID. - :vartype subscription_id: str - :ivar display_name: The subscription display name. - :vartype display_name: str - :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". - :vartype state: str or ~subscription_client.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: ~subscription_client.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or - more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, - RoleBased'. - :type authorization_source: str + :ivar name: Alias ID. + :vartype name: str + :ivar type: Resource type, Microsoft.Subscription/aliases. + :vartype type: str + :param properties: Subscription Alias response properties. + :type properties: ~azure.mgmt.subscription.models.SubscriptionAliasResponseProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.subscription.models.SystemData """ _validation = { 'id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'state': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'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'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SubscriptionAliasResponseProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, - authorization_source: Optional[str] = None, + properties: Optional["SubscriptionAliasResponseProperties"] = None, **kwargs ): - super(Subscription, self).__init__(**kwargs) + super(SubscriptionAliasResponse, 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 + self.name = None + self.type = None + self.properties = properties + self.system_data = None -class SubscriptionListResult(msrest.serialization.Model): - """Subscription list operation response. +class SubscriptionAliasResponseProperties(msrest.serialization.Model): + """Put subscription creation result properties. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of subscriptions. - :type value: list[~subscription_client.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar subscription_id: Newly created subscription Id. + :vartype subscription_id: str + :param display_name: The display name of the subscription. + :type display_name: str + :param provisioning_state: The provisioning state of the resource. Possible values include: + "Accepted", "Succeeded", "Failed". + :type provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState + :ivar accept_ownership_url: Url to accept ownership of the subscription. + :vartype accept_ownership_url: str + :ivar accept_ownership_state: The accept ownership state of the resource. Possible values + include: "Pending", "Completed", "Expired". + :vartype accept_ownership_state: str or ~azure.mgmt.subscription.models.AcceptOwnership + :param billing_scope: Billing scope of the subscription. + For CustomerLed and FieldLed - + /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + For Legacy EA - + /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}. + :type billing_scope: str + :param workload: The workload type of the subscription. It can be either Production or DevTest. + Possible values include: "Production", "DevTest". + :type workload: str or ~azure.mgmt.subscription.models.Workload + :param reseller_id: Reseller Id. + :type reseller_id: str + :param subscription_owner_id: Owner Id of the subscription. + :type subscription_owner_id: str + :param management_group_id: The Management Group Id. + :type management_group_id: str + :param tags: A set of tags. Tags for the subscription. + :type tags: dict[str, str] """ _validation = { - 'next_link': {'required': True}, + 'subscription_id': {'readonly': True}, + 'accept_ownership_url': {'readonly': True}, + 'accept_ownership_state': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Subscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'accept_ownership_url': {'key': 'acceptOwnershipUrl', 'type': 'str'}, + 'accept_ownership_state': {'key': 'acceptOwnershipState', 'type': 'str'}, + 'billing_scope': {'key': 'billingScope', 'type': 'str'}, + 'workload': {'key': 'workload', 'type': 'str'}, + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'subscription_owner_id': {'key': 'subscriptionOwnerId', 'type': 'str'}, + 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, *, - next_link: str, - value: Optional[List["Subscription"]] = None, + display_name: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + billing_scope: Optional[str] = None, + workload: Optional[Union[str, "Workload"]] = None, + reseller_id: Optional[str] = None, + subscription_owner_id: Optional[str] = None, + management_group_id: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, **kwargs ): - super(SubscriptionListResult, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + super(SubscriptionAliasResponseProperties, self).__init__(**kwargs) + self.subscription_id = None + self.display_name = display_name + self.provisioning_state = provisioning_state + self.accept_ownership_url = None + self.accept_ownership_state = None + self.billing_scope = billing_scope + self.workload = workload + self.reseller_id = reseller_id + self.subscription_owner_id = subscription_owner_id + self.management_group_id = management_group_id + self.tags = tags class SubscriptionName(msrest.serialization.Model): @@ -572,102 +850,93 @@ def __init__( self.subscription_name = subscription_name -class SubscriptionPolicies(msrest.serialization.Model): - """Subscription policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location_placement_id: The subscription location placement ID. The ID indicates which - regions are visible for a subscription. For example, a subscription with a location placement - Id of Public_2014-09-01 has access to Azure public regions. - :vartype location_placement_id: str - :ivar quota_id: The subscription quota ID. - :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", - "CurrentPeriodOff". - :vartype spending_limit: str or ~subscription_client.models.SpendingLimit +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime """ - _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'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } def __init__( self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SubscriptionPolicies, self).__init__(**kwargs) - self.location_placement_id = None - self.quota_id = None - self.spending_limit = None + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at -class TenantIdDescription(msrest.serialization.Model): - """Tenant Id information. +class TenantPolicy(msrest.serialization.Model): + """Tenant policy. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The fully qualified ID of the tenant. For example, - /tenants/00000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. - :vartype tenant_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantIdDescription, self).__init__(**kwargs) - self.id = None - self.tenant_id = None - - -class TenantListResult(msrest.serialization.Model): - """Tenant Ids information. - - All required parameters must be populated in order to send to Azure. - - :param value: An array of tenants. - :type value: list[~subscription_client.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar policy_id: Policy Id. + :vartype policy_id: str + :param block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :type block_subscriptions_leaving_tenant: bool + :param block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :type block_subscriptions_into_tenant: bool + :param exempted_principals: List of user objectIds that are exempted from the set subscription + tenant policies for the user's tenant. + :type exempted_principals: list[str] """ _validation = { - 'next_link': {'required': True}, + 'policy_id': {'readonly': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'policy_id': {'key': 'policyId', 'type': 'str'}, + 'block_subscriptions_leaving_tenant': {'key': 'blockSubscriptionsLeavingTenant', 'type': 'bool'}, + 'block_subscriptions_into_tenant': {'key': 'blockSubscriptionsIntoTenant', 'type': 'bool'}, + 'exempted_principals': {'key': 'exemptedPrincipals', 'type': '[str]'}, } def __init__( self, *, - next_link: str, - value: Optional[List["TenantIdDescription"]] = None, + block_subscriptions_leaving_tenant: Optional[bool] = None, + block_subscriptions_into_tenant: Optional[bool] = None, + exempted_principals: Optional[List[str]] = None, **kwargs ): - super(TenantListResult, self).__init__(**kwargs) - self.value = value - self.next_link = next_link + super(TenantPolicy, self).__init__(**kwargs) + self.policy_id = None + self.block_subscriptions_leaving_tenant = block_subscriptions_leaving_tenant + self.block_subscriptions_into_tenant = block_subscriptions_into_tenant + self.exempted_principals = exempted_principals diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_subscription_client_enums.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_subscription_client_enums.py index 18d7d3d3fcc1c..d413f46c84589 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_subscription_client_enums.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_subscription_client_enums.py @@ -26,31 +26,30 @@ def __getattr__(cls, name): raise AttributeError(name) -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource. +class AcceptOwnership(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The accept ownership state of the resource. """ - ACCEPTED = "Accepted" - SUCCEEDED = "Succeeded" - FAILED = "Failed" + PENDING = "Pending" + COMPLETED = "Completed" + EXPIRED = "Expired" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription spending limit. +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. """ - ON = "On" - OFF = "Off" - CURRENT_PERIOD_OFF = "CurrentPeriodOff" + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The provisioning state of the resource. """ - ENABLED = "Enabled" - WARNED = "Warned" - PAST_DUE = "PastDue" - DISABLED = "Disabled" - DELETED = "Deleted" + ACCEPTED = "Accepted" + SUCCEEDED = "Succeeded" + FAILED = "Failed" class Workload(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The workload type of the subscription. It can be either Production or DevTest. diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py index 4831f8016e904..524c3eb800b82 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py @@ -6,16 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._subscriptions_operations import SubscriptionsOperations -from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations from ._operations import Operations from ._alias_operations import AliasOperations +from ._subscription_policy_operations import SubscriptionPolicyOperations +from ._billing_account_operations import BillingAccountOperations __all__ = [ - 'SubscriptionsOperations', - 'TenantsOperations', 'SubscriptionOperations', 'Operations', 'AliasOperations', + 'SubscriptionPolicyOperations', + 'BillingAccountOperations', ] diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py index 82a74dba009d5..4e2e789af475e 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py @@ -15,7 +15,7 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -31,14 +31,14 @@ class AliasOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,16 +49,16 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, alias_name, # type: str - body, # type: "models.PutAliasRequest" + body, # type: "_models.PutAliasRequest" **kwargs # type: Any ): - # type: (...) -> "models.PutAliasResponse" - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + # type: (...) -> "_models.SubscriptionAliasResponse" + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -87,14 +87,14 @@ def _create_initial( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -105,28 +105,30 @@ def _create_initial( def begin_create( self, alias_name, # type: str - body, # type: "models.PutAliasRequest" + body, # type: "_models.PutAliasRequest" **kwargs # type: Any ): - # type: (...) -> LROPoller["models.PutAliasResponse"] + # type: (...) -> LROPoller["_models.SubscriptionAliasResponse"] """Create Alias Subscription. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :param body: - :type body: ~subscription_client.models.PutAliasRequest + :type body: ~azure.mgmt.subscription.models.PutAliasRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PutAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~subscription_client.models.PutAliasResponse] + :return: An instance of LROPoller that returns either SubscriptionAliasResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -144,13 +146,17 @@ def begin_create( kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -169,22 +175,24 @@ def get( alias_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.PutAliasResponse" + # type: (...) -> "_models.SubscriptionAliasResponse" """Get Alias Subscription. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PutAliasResponse, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasResponse + :return: SubscriptionAliasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -208,10 +216,10 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PutAliasResponse', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -227,7 +235,9 @@ def delete( # type: (...) -> None """Delete Alias. - :param alias_name: Alias Name. + :param alias_name: AliasName is the name for the subscription creation request. Note that this + is not the same as subscription name and this doesn’t have any other lifecycle need beyond the + request for subscription creation. :type alias_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -239,7 +249,7 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -263,7 +273,7 @@ def delete( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -275,20 +285,20 @@ def list( self, **kwargs # type: Any ): - # type: (...) -> "models.PutAliasListResult" - """Get Alias Subscription. + # type: (...) -> "_models.SubscriptionAliasListResult" + """List Alias Subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: PutAliasListResult, or the result of cls(response) - :rtype: ~subscription_client.models.PutAliasListResult + :return: SubscriptionAliasListResult, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.PutAliasListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -308,10 +318,10 @@ def list( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PutAliasListResult', pipeline_response) + deserialized = self._deserialize('SubscriptionAliasListResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py new file mode 100644 index 0000000000000..2b5a7b75ccca5 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_billing_account_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import 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 as _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 BillingAccountOperations(object): + """BillingAccountOperations 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.subscription.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 get_policy( + self, + billing_account_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.BillingAccountPoliciesResponse" + """Get Billing Account Policy. + + :param billing_account_id: Billing Account Id. + :type billing_account_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingAccountPoliciesResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccountPoliciesResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + accept = "application/json" + + # Construct URL + url = self.get_policy.metadata['url'] # type: ignore + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BillingAccountPoliciesResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_policy.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py index a8de683e0452d..1ca2ebb5cd7da 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_operations.py @@ -9,15 +9,16 @@ 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 +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -29,14 +30,14 @@ class Operations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -48,46 +49,62 @@ def list( self, **kwargs # type: Any ): - # type: (...) -> "models.OperationListResult" + # type: (...) -> Iterable["_models.OperationListResult"] """Lists all of the available Microsoft.Subscription API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) - :rtype: ~subscription_client.models.OperationListResult + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + 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 = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 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) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('OperationListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + 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]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py index 41e4e3a98f3af..c08b23165ca34 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py @@ -11,13 +11,15 @@ 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.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -29,14 +31,14 @@ class SubscriptionOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,22 +51,22 @@ def cancel( subscription_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.CanceledSubscriptionId" + # type: (...) -> "_models.CanceledSubscriptionId" """The operation to cancel a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CanceledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.CanceledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.CanceledSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.CanceledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -88,7 +90,7 @@ def cancel( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) @@ -102,27 +104,27 @@ def cancel( def rename( self, subscription_id, # type: str - body, # type: "models.SubscriptionName" + body, # type: "_models.SubscriptionName" **kwargs # type: Any ): - # type: (...) -> "models.RenamedSubscriptionId" + # type: (...) -> "_models.RenamedSubscriptionId" """The operation to rename a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :param body: Subscription Name. - :type body: ~subscription_client.models.SubscriptionName + :type body: ~azure.mgmt.subscription.models.SubscriptionName :keyword callable cls: A custom type or function that will be passed the direct response :return: RenamedSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.RenamedSubscriptionId + :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.RenamedSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.RenamedSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -151,7 +153,7 @@ def rename( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) @@ -167,22 +169,22 @@ def enable( subscription_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.EnabledSubscriptionId" + # type: (...) -> "_models.EnabledSubscriptionId" """The operation to enable a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EnabledSubscriptionId, or the result of cls(response) - :rtype: ~subscription_client.models.EnabledSubscriptionId + :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.EnabledSubscriptionId"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.EnabledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" + api_version = "2021-10-01" accept = "application/json" # Construct URL @@ -206,7 +208,7 @@ def enable( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) @@ -216,3 +218,174 @@ def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + + def _accept_ownership_initial( + self, + subscription_id, # type: str + body, # type: "_models.AcceptOwnershipRequest" + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._accept_ownership_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'AcceptOwnershipRequest') + 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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _accept_ownership_initial.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership'} # type: ignore + + def begin_accept_ownership( + self, + subscription_id, # type: str + body, # type: "_models.AcceptOwnershipRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Accept subscription ownership. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :param body: + :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._accept_ownership_initial( + subscription_id=subscription_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_accept_ownership.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership'} # type: ignore + + def accept_ownership_status( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.AcceptOwnershipStatusResponse" + """Accept subscription ownership status. + + :param subscription_id: Subscription Id. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AcceptOwnershipStatusResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.AcceptOwnershipStatusResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AcceptOwnershipStatusResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-01" + accept = "application/json" + + # Construct URL + url = self.accept_ownership_status.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AcceptOwnershipStatusResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + accept_ownership_status.metadata = {'url': '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py similarity index 53% rename from sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py rename to sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py index 4198de5d24712..d023d1160ba87 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py @@ -14,7 +14,7 @@ from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.mgmt.core.exceptions import ARMErrorFormat -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -23,21 +23,21 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. +class SubscriptionPolicyOperations(object): + """SubscriptionPolicyOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models + :type models: ~azure.mgmt.subscription.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 + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,108 +45,84 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list_locations( + def add_update_policy_for_tenant( self, - subscription_id, # type: str + body, # type: "_models.PutTenantPolicyRequestProperties" **kwargs # type: Any ): - # type: (...) -> Iterable["models.LocationListResult"] - """Gets all available geo-locations. + # type: (...) -> "_models.GetTenantPolicyResponse" + """Create or Update Subscription tenant policy for user's tenant. - 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 + :param body: + :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.LocationListResult] + :return: GetTenantPolicyResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.LocationListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-01" + content_type = kwargs.pop("content_type", "application/json") 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') + # Construct URL + url = self.add_update_policy_for_tenant.metadata['url'] # type: ignore - 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 + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - 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) + # 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') - def get_next(next_link=None): - request = prepare_request(next_link) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PutTenantPolicyRequestProperties') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - 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('GetTenantPolicyResponse', pipeline_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) - return ItemPaged( - get_next, extract_data - ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + return deserialized + add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore - def get( + def get_policy_for_tenant( self, - subscription_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.Subscription" - """Gets details about a specified subscription. + # type: (...) -> "_models.GetTenantPolicyResponse" + """Get the subscription tenant policy for the user's tenant. - :param subscription_id: The ID of the target subscription. - :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Subscription, or the result of cls(response) - :rtype: ~subscription_client.models.Subscription + :return: GetTenantPolicyResponse, or the result of cls(response) + :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-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) + url = self.get_policy_for_tenant.metadata['url'] # type: ignore # Construct parameters query_parameters = {} # type: Dict[str, Any] @@ -162,34 +138,35 @@ def get( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Subscription', pipeline_response) + deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore - def list( + def list_policy_for_tenant( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.SubscriptionListResult"] - """Gets all subscriptions for a tenant. + # type: (...) -> Iterable["_models.GetTenantPolicyListResponse"] + """Get the subscription tenant policy for the user's tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.SubscriptionListResult] + :return: An iterator like instance of either GetTenantPolicyListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" + api_version = "2021-10-01" accept = "application/json" def prepare_request(next_link=None): @@ -199,7 +176,7 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] # type: ignore + url = self.list_policy_for_tenant.metadata['url'] # type: ignore # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') @@ -212,7 +189,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize('GetTenantPolicyListResponse', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -225,12 +202,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions'} # type: ignore + list_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies'} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py deleted file mode 100644 index 9d433ae62466a..0000000000000 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TenantsOperations(object): - """TenantsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~subscription_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.TenantListResult"] - """Gets the tenants for your account. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~subscription_client.models.TenantListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TenantListResult"] - error_map = { - 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