From 611702ff98667c6b9b996ad50e6999f36038e251 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 12:52:27 +0000 Subject: [PATCH] CodeGen from PR 17000 in Azure/azure-rest-api-specs [Go] Track2 modify readme.go.md 9 (#17000) * [Go] Track2 modify readme.go.md 9 * fix --- .../azure-mgmt-subscription/_meta.json | 10 +- .../azure/mgmt/subscription/__init__.py | 9 +- .../azure/mgmt/subscription/_configuration.py | 17 +- .../azure/mgmt/subscription/_metadata.json | 21 +- .../azure/mgmt/subscription/_patch.py | 31 + .../mgmt/subscription/_subscription_client.py | 91 +- .../azure/mgmt/subscription/_vendor.py | 27 + .../azure/mgmt/subscription/_version.py | 2 +- .../azure/mgmt/subscription/aio/__init__.py | 5 + .../mgmt/subscription/aio/_configuration.py | 6 +- .../azure/mgmt/subscription/aio/_patch.py | 31 + .../subscription/aio/_subscription_client.py | 84 +- .../aio/operations/_alias_operations.py | 157 ++-- .../operations/_billing_account_operations.py | 37 +- .../aio/operations/_operations.py | 47 +- .../operations/_subscription_operations.py | 192 ++-- .../_subscription_policy_operations.py | 112 ++- .../mgmt/subscription/models/__init__.py | 81 +- .../azure/mgmt/subscription/models/_models.py | 856 ------------------ .../mgmt/subscription/models/_models_py3.py | 440 ++++++--- .../models/_subscription_client_enums.py | 27 +- .../operations/_alias_operations.py | 334 ++++--- .../operations/_billing_account_operations.py | 87 +- .../subscription/operations/_operations.py | 85 +- .../operations/_subscription_operations.py | 426 ++++++--- .../_subscription_policy_operations.py | 225 +++-- 26 files changed, 1567 insertions(+), 1873 deletions(-) create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_patch.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_patch.py delete mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py diff --git a/sdk/subscription/azure-mgmt-subscription/_meta.json b/sdk/subscription/azure-mgmt-subscription/_meta.json index a5bc3879545e2..7f5adf59f19b7 100644 --- a/sdk/subscription/azure-mgmt-subscription/_meta.json +++ b/sdk/subscription/azure-mgmt-subscription/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "417fa30d2449b9aa56dab2b991a4e799a31f8cd4", + "commit": "2ab4371edba33c23e8d680ed2bf6f98705b5cadb", "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", + "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 --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "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 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 2a8168883ad65..4b23d4a4b060a 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class SubscriptionClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-10-01" @@ -62,4 +59,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **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 index 55dcec15a0825..baa8f6024f98f 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "The subscription client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"]}}}" + "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\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"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\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "subscription": "SubscriptionOperations", diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_patch.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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 ae0fa246a91b5..987b72dc25ac7 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 @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import AliasOperations, BillingAccountOperations, Operations, SubscriptionOperations, SubscriptionPolicyOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - 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 SubscriptionOperations -from .operations import Operations -from .operations import AliasOperations -from .operations import SubscriptionPolicyOperations -from .operations import BillingAccountOperations -from . import models - -class SubscriptionClient(object): +class SubscriptionClient: """The subscription client. :ivar subscription: SubscriptionOperations operations @@ -42,52 +36,57 @@ class SubscriptionClient(object): :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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) - 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 + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: 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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) 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 48944bf3938a2..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 = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 2e6b5bb3e1757..11ae84113ed0c 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-10-01" @@ -58,4 +58,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_patch.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 554abcaaeeeb1..78928fb6494e9 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 @@ -6,26 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import AliasOperations, BillingAccountOperations, Operations, SubscriptionOperations, SubscriptionPolicyOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -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): +class SubscriptionClient: """The subscription client. :ivar subscription: SubscriptionOperations operations @@ -35,55 +31,63 @@ class SubscriptionClient(object): :ivar alias: AliasOperations operations :vartype alias: azure.mgmt.subscription.aio.operations.AliasOperations :ivar subscription_policy: SubscriptionPolicyOperations operations - :vartype subscription_policy: azure.mgmt.subscription.aio.operations.SubscriptionPolicyOperations + :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + 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) + - 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: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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 6243d1997b578..a126f0cc5f6c6 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 @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._alias_operations import build_create_request_initial, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,37 +57,26 @@ async def _create_initial( 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._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(body, 'PutAliasRequest') + + request = build_create_request_initial( + alias_name=alias_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'PutAliasRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) @@ -95,8 +88,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, alias_name: str, @@ -113,15 +109,20 @@ async def begin_create( :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: 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. + :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 SubscriptionAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] - :raises ~azure.core.exceptions.HttpResponseError: + :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 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] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -132,25 +133,21 @@ async def begin_create( raw_result = await self._create_initial( alias_name=alias_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -162,8 +159,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + @distributed_trace_async async def get( self, alias_name: str, @@ -185,31 +184,21 @@ async def get( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + alias_name=alias_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) @@ -218,8 +207,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace_async async def delete( self, alias_name: str, @@ -241,31 +233,21 @@ async def delete( 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.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + alias_name=alias_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -273,6 +255,8 @@ async def delete( delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace_async async def list( self, **kwargs: Any @@ -289,27 +273,20 @@ async def list( 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.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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionAliasListResult', pipeline_response) @@ -318,4 +295,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore + 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 index f9ec52a660c2a..00f1cc1f156b7 100644 --- 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_account_operations import build_get_policy_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_policy( self, billing_account_id: str, @@ -59,31 +64,21 @@ async def get_policy( 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') + + request = build_get_policy_request( + billing_account_id=billing_account_id, + template_url=self.get_policy.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingAccountPoliciesResponse', pipeline_response) @@ -92,4 +87,6 @@ async def get_policy( 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 fb8fc76380c45..50b190fe7e74a 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,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.OperationListResult] + :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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 dd7d51e131f38..623b9e6c47974 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,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_operations import build_accept_ownership_request_initial, build_accept_ownership_status_request, build_cancel_request, build_enable_request, build_rename_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def cancel( self, subscription_id: str, @@ -61,31 +66,21 @@ async def cancel( 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.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + subscription_id=subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) @@ -94,8 +89,11 @@ async def cancel( return cls(pipeline_response, deserialized, {}) return deserialized + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + + @distributed_trace_async async def rename( self, subscription_id: str, @@ -118,36 +116,26 @@ async def rename( 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.rename.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(body, 'SubscriptionName') + + request = build_rename_request( + subscription_id=subscription_id, + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'SubscriptionName') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) @@ -156,8 +144,11 @@ async def rename( return cls(pipeline_response, deserialized, {}) return deserialized + rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + + @distributed_trace_async async def enable( self, subscription_id: str, @@ -177,31 +168,21 @@ async def enable( 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.enable.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_enable_request( + subscription_id=subscription_id, + template_url=self.enable.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) @@ -210,8 +191,10 @@ async def enable( return cls(pipeline_response, deserialized, {}) return deserialized + enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + async def _accept_ownership_initial( self, subscription_id: str, @@ -223,47 +206,39 @@ async def _accept_ownership_initial( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(body, 'AcceptOwnershipRequest') + + request = build_accept_ownership_request_initial( + subscription_id=subscription_id, + content_type=content_type, + json=_json, + template_url=self._accept_ownership_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + raise HttpResponseError(response=response, 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 + + @distributed_trace_async async def begin_accept_ownership( self, subscription_id: str, @@ -278,15 +253,18 @@ async def begin_accept_ownership( :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. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -297,22 +275,18 @@ async def begin_accept_ownership( raw_result = await self._accept_ownership_initial( subscription_id=subscription_id, body=body, + content_type=content_type, 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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -324,8 +298,10 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace_async async def accept_ownership_status( self, subscription_id: str, @@ -345,31 +321,21 @@ async def accept_ownership_status( 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 = build_accept_ownership_status_request( + subscription_id=subscription_id, + template_url=self.accept_ownership_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AcceptOwnershipStatusResponse', pipeline_response) @@ -378,4 +344,6 @@ async def accept_ownership_status( 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/_subscription_policy_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py index a7ab886319714..748ba5cdf357e 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscription_policy_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_policy_operations import build_add_update_policy_for_tenant_request, build_get_policy_for_tenant_request, build_list_policy_for_tenant_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def add_update_policy_for_tenant( self, body: "_models.PutTenantPolicyRequestProperties", @@ -60,32 +66,25 @@ async def add_update_policy_for_tenant( 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.add_update_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') - - # 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, 'PutTenantPolicyRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'PutTenantPolicyRequestProperties') + + request = build_add_update_policy_for_tenant_request( + content_type=content_type, + json=_json, + template_url=self.add_update_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) @@ -94,8 +93,11 @@ async def add_update_policy_for_tenant( return cls(pipeline_response, deserialized, {}) return deserialized + add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + + @distributed_trace_async async def get_policy_for_tenant( self, **kwargs: Any @@ -112,27 +114,20 @@ async def get_policy_for_tenant( 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_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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_policy_for_tenant_request( + template_url=self.get_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) @@ -141,8 +136,11 @@ async def get_policy_for_tenant( return cls(pipeline_response, deserialized, {}) return deserialized + get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + + @distributed_trace def list_policy_for_tenant( self, **kwargs: Any @@ -150,8 +148,10 @@ def list_policy_for_tenant( """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 GetTenantPolicyListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] + :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.GetTenantPolicyListResponse"] @@ -159,30 +159,27 @@ def list_policy_for_tenant( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-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_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') + + request = build_list_policy_for_tenant_request( + template_url=self.list_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_policy_for_tenant_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GetTenantPolicyListResponse', pipeline_response) + deserialized = self._deserialize("GetTenantPolicyListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -195,12 +192,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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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 323f5910c6859..f28faa95ef125 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 @@ -6,60 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 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 PutAliasRequest - from ._models_py3 import PutAliasRequestAdditionalProperties - from ._models_py3 import PutAliasRequestProperties - from ._models_py3 import PutTenantPolicyRequestProperties - from ._models_py3 import RenamedSubscriptionId - 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 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 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 PutAliasRequest # type: ignore - from ._models import PutAliasRequestAdditionalProperties # type: ignore - from ._models import PutAliasRequestProperties # type: ignore - from ._models import PutTenantPolicyRequestProperties # type: ignore - from ._models import RenamedSubscriptionId # 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 SystemData # type: ignore - from ._models import TenantPolicy # type: ignore +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 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 PutAliasRequest +from ._models_py3 import PutAliasRequestAdditionalProperties +from ._models_py3 import PutAliasRequestProperties +from ._models_py3 import PutTenantPolicyRequestProperties +from ._models_py3 import RenamedSubscriptionId +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 SystemData +from ._models_py3 import TenantPolicy + from ._subscription_client_enums import ( AcceptOwnership, 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 deleted file mode 100644 index 90d5a50007c73..0000000000000 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py +++ /dev/null @@ -1,856 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The ID of the canceled subscription. - :vartype value: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CanceledSubscriptionId, self).__init__(**kwargs) - self.value = None - - -class EnabledSubscriptionId(msrest.serialization.Model): - """The ID of the subscriptions that is being enabled. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The ID of the subscriptions that is being enabled. - :vartype value: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnabledSubscriptionId, self).__init__(**kwargs) - self.value = None - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -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: ~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, - **kwargs - ): - super(ErrorResponseBody, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -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 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 = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GetTenantPolicyResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GetTenantPolicyListResponse, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class GetTenantPolicyResponse(msrest.serialization.Model): - """Tenant policy Information. - - 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 = { - '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(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): - """REST API operation. - - :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: ~azure.mgmt.subscription.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - 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) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.Subscription. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: 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__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of operations. - :type value: list[~azure.mgmt.subscription.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PutAliasRequest(msrest.serialization.Model): - """The parameters required to create a new subscription. - - :param properties: Put alias request properties. - :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PutAliasRequest, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PutAliasRequestAdditionalProperties(msrest.serialization.Model): - """Put subscription additional properties. - - :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] - """ - - _attribute_map = { - '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(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): - """Put subscription properties. - - :param display_name: The friendly name of the subscription. - :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 ~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. - :type reseller_id: str - :param additional_properties: Put alias request additional properties. - :type additional_properties: - ~azure.mgmt.subscription.models.PutAliasRequestAdditionalProperties - """ - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'workload': {'key': 'workload', 'type': 'str'}, - '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__( - self, - **kwargs - ): - super(PutAliasRequestProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.workload = kwargs.get('workload', None) - 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 PutTenantPolicyRequestProperties(msrest.serialization.Model): - """Put tenant policy request properties. - - :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] - """ - - _attribute_map = { - '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(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 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 value: The ID of the subscriptions that is being renamed. - :vartype value: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - '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, - **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 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': '[SubscriptionAliasResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionAliasListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -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: 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: 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}, - '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': 'SubscriptionAliasResponseProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionAliasResponse, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs.get('properties', None) - self.system_data = None - - -class SubscriptionAliasResponseProperties(msrest.serialization.Model): - """Put subscription creation result properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar subscription_id: Newly created subscription Id. - :vartype subscription_id: str - :param 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 = { - 'subscription_id': {'readonly': True}, - 'accept_ownership_url': {'readonly': True}, - 'accept_ownership_state': {'readonly': True}, - } - - _attribute_map = { - '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(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): - """The new name of the subscription. - - :param subscription_name: New subscription name. - :type subscription_name: str - """ - - _attribute_map = { - 'subscription_name': {'key': 'subscriptionName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionName, self).__init__(**kwargs) - self.subscription_name = kwargs.get('subscription_name', None) - - -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 - """ - - _attribute_map = { - '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(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 TenantPolicy(msrest.serialization.Model): - """Tenant policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 = { - 'policy_id': {'readonly': True}, - } - - _attribute_map = { - '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(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 c253155dafe0c..a8b95c0b73273 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 @@ -18,8 +18,8 @@ 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 + :ivar properties: Accept subscription ownership request properties. + :vartype properties: ~azure.mgmt.subscription.models.AcceptOwnershipRequestProperties """ _attribute_map = { @@ -32,6 +32,10 @@ def __init__( properties: Optional["AcceptOwnershipRequestProperties"] = None, **kwargs ): + """ + :keyword properties: Accept subscription ownership request properties. + :paramtype properties: ~azure.mgmt.subscription.models.AcceptOwnershipRequestProperties + """ super(AcceptOwnershipRequest, self).__init__(**kwargs) self.properties = properties @@ -41,12 +45,12 @@ class AcceptOwnershipRequestProperties(msrest.serialization.Model): 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] + :ivar display_name: Required. The friendly name of the subscription. + :vartype display_name: str + :ivar management_group_id: Management group Id for the subscription. + :vartype management_group_id: str + :ivar tags: A set of tags. Tags for the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -67,6 +71,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword display_name: Required. The friendly name of the subscription. + :paramtype display_name: str + :keyword management_group_id: Management group Id for the subscription. + :paramtype management_group_id: str + :keyword tags: A set of tags. Tags for the subscription. + :paramtype tags: dict[str, str] + """ super(AcceptOwnershipRequestProperties, self).__init__(**kwargs) self.display_name = display_name self.management_group_id = management_group_id @@ -85,12 +97,12 @@ class AcceptOwnershipStatusResponse(msrest.serialization.Model): :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] + :ivar subscription_tenant_id: Tenant Id of the subscription. + :vartype subscription_tenant_id: str + :ivar display_name: The display name of the subscription. + :vartype display_name: str + :ivar tags: A set of tags. Tags for the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -116,6 +128,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword subscription_tenant_id: Tenant Id of the subscription. + :paramtype subscription_tenant_id: str + :keyword display_name: The display name of the subscription. + :paramtype display_name: str + :keyword tags: A set of tags. Tags for the subscription. + :paramtype tags: dict[str, str] + """ super(AcceptOwnershipStatusResponse, self).__init__(**kwargs) self.subscription_id = None self.accept_ownership_state = None @@ -136,8 +156,8 @@ class BillingAccountPoliciesResponse(msrest.serialization.Model): :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 properties: Billing account policies response properties. + :vartype 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 """ @@ -163,6 +183,10 @@ def __init__( properties: Optional["BillingAccountPoliciesResponseProperties"] = None, **kwargs ): + """ + :keyword properties: Billing account policies response properties. + :paramtype properties: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponseProperties + """ super(BillingAccountPoliciesResponse, self).__init__(**kwargs) self.id = None self.name = None @@ -174,10 +198,10 @@ def __init__( 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 + :ivar service_tenants: Service tenant for the billing account. + :vartype service_tenants: list[~azure.mgmt.subscription.models.ServiceTenantResponse] + :ivar allow_transfers: Determine if the transfers are allowed for the billing account. + :vartype allow_transfers: bool """ _attribute_map = { @@ -192,6 +216,12 @@ def __init__( allow_transfers: Optional[bool] = None, **kwargs ): + """ + :keyword service_tenants: Service tenant for the billing account. + :paramtype service_tenants: list[~azure.mgmt.subscription.models.ServiceTenantResponse] + :keyword allow_transfers: Determine if the transfers are allowed for the billing account. + :paramtype allow_transfers: bool + """ super(BillingAccountPoliciesResponseProperties, self).__init__(**kwargs) self.service_tenants = service_tenants self.allow_transfers = allow_transfers @@ -218,6 +248,8 @@ def __init__( self, **kwargs ): + """ + """ super(CanceledSubscriptionId, self).__init__(**kwargs) self.value = None @@ -243,6 +275,8 @@ def __init__( self, **kwargs ): + """ + """ super(EnabledSubscriptionId, self).__init__(**kwargs) self.value = None @@ -250,10 +284,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -268,6 +302,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -276,12 +316,12 @@ def __init__( 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: ~azure.mgmt.subscription.models.ErrorResponse - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.subscription.models.ErrorResponse + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -298,6 +338,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.subscription.models.ErrorResponse + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponseBody, self).__init__(**kwargs) self.error = error self.code = code @@ -329,6 +377,8 @@ def __init__( self, **kwargs ): + """ + """ super(GetTenantPolicyListResponse, self).__init__(**kwargs) self.value = None self.next_link = None @@ -345,8 +395,8 @@ class GetTenantPolicyResponse(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param properties: Tenant policy properties. - :type properties: ~azure.mgmt.subscription.models.TenantPolicy + :ivar properties: Tenant policy properties. + :vartype 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 """ @@ -372,6 +422,10 @@ def __init__( properties: Optional["TenantPolicy"] = None, **kwargs ): + """ + :keyword properties: Tenant policy properties. + :paramtype properties: ~azure.mgmt.subscription.models.TenantPolicy + """ super(GetTenantPolicyResponse, self).__init__(**kwargs) self.id = None self.name = None @@ -383,12 +437,12 @@ def __init__( class Operation(msrest.serialization.Model): """REST API operation. - :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: ~azure.mgmt.subscription.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.subscription.models.OperationDisplay """ _attribute_map = { @@ -405,6 +459,14 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.subscription.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -414,14 +476,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Subscription. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Localized friendly description for the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Subscription. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str """ _attribute_map = { @@ -440,6 +502,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Subscription. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Localized friendly description for the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -450,10 +522,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of operations. - :type value: list[~azure.mgmt.subscription.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations. + :vartype value: list[~azure.mgmt.subscription.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -468,6 +540,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations. + :paramtype value: list[~azure.mgmt.subscription.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -476,8 +554,8 @@ def __init__( class PutAliasRequest(msrest.serialization.Model): """The parameters required to create a new subscription. - :param properties: Put alias request properties. - :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties + :ivar properties: Put alias request properties. + :vartype properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ _attribute_map = { @@ -490,6 +568,10 @@ def __init__( properties: Optional["PutAliasRequestProperties"] = None, **kwargs ): + """ + :keyword properties: Put alias request properties. + :paramtype properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties + """ super(PutAliasRequest, self).__init__(**kwargs) self.properties = properties @@ -497,14 +579,14 @@ def __init__( class PutAliasRequestAdditionalProperties(msrest.serialization.Model): """Put subscription additional properties. - :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] + :ivar management_group_id: Management group Id for the subscription. + :vartype management_group_id: str + :ivar subscription_tenant_id: Tenant Id of the subscription. + :vartype subscription_tenant_id: str + :ivar subscription_owner_id: Owner Id of the subscription. + :vartype subscription_owner_id: str + :ivar tags: A set of tags. Tags for the subscription. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -523,6 +605,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword management_group_id: Management group Id for the subscription. + :paramtype management_group_id: str + :keyword subscription_tenant_id: Tenant Id of the subscription. + :paramtype subscription_tenant_id: str + :keyword subscription_owner_id: Owner Id of the subscription. + :paramtype subscription_owner_id: str + :keyword tags: A set of tags. Tags for the subscription. + :paramtype tags: dict[str, str] + """ super(PutAliasRequestAdditionalProperties, self).__init__(**kwargs) self.management_group_id = management_group_id self.subscription_tenant_id = subscription_tenant_id @@ -533,25 +625,24 @@ def __init__( class PutAliasRequestProperties(msrest.serialization.Model): """Put subscription properties. - :param display_name: The friendly name of the subscription. - :type display_name: str - :param workload: The workload type of the subscription. It can be either Production or DevTest. + :ivar display_name: The friendly name of the subscription. + :vartype display_name: str + :ivar 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 billing_scope: Billing scope of the subscription. + :vartype workload: str or ~azure.mgmt.subscription.models.Workload + :ivar 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. - :type reseller_id: str - :param additional_properties: Put alias request additional properties. - :type additional_properties: + :vartype billing_scope: str + :ivar subscription_id: This parameter can be used to create alias for existing subscription Id. + :vartype subscription_id: str + :ivar reseller_id: Reseller Id. + :vartype reseller_id: str + :ivar additional_properties: Put alias request additional properties. + :vartype additional_properties: ~azure.mgmt.subscription.models.PutAliasRequestAdditionalProperties """ @@ -575,6 +666,28 @@ def __init__( additional_properties: Optional["PutAliasRequestAdditionalProperties"] = None, **kwargs ): + """ + :keyword display_name: The friendly name of the subscription. + :paramtype display_name: str + :keyword workload: The workload type of the subscription. It can be either Production or + DevTest. Possible values include: "Production", "DevTest". + :paramtype workload: str or ~azure.mgmt.subscription.models.Workload + :keyword 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}. + :paramtype billing_scope: str + :keyword subscription_id: This parameter can be used to create alias for existing subscription + Id. + :paramtype subscription_id: str + :keyword reseller_id: Reseller Id. + :paramtype reseller_id: str + :keyword additional_properties: Put alias request additional properties. + :paramtype additional_properties: + ~azure.mgmt.subscription.models.PutAliasRequestAdditionalProperties + """ super(PutAliasRequestProperties, self).__init__(**kwargs) self.display_name = display_name self.workload = workload @@ -587,15 +700,14 @@ def __init__( class PutTenantPolicyRequestProperties(msrest.serialization.Model): """Put tenant policy request properties. - :param block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + :ivar 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 + :vartype block_subscriptions_leaving_tenant: bool + :ivar block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's tenant. + :vartype block_subscriptions_into_tenant: bool + :ivar 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] + :vartype exempted_principals: list[str] """ _attribute_map = { @@ -612,6 +724,17 @@ def __init__( exempted_principals: Optional[List[str]] = None, **kwargs ): + """ + :keyword block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :paramtype block_subscriptions_leaving_tenant: bool + :keyword block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :paramtype block_subscriptions_into_tenant: bool + :keyword exempted_principals: List of user objectIds that are exempted from the set + subscription tenant policies for the user's tenant. + :paramtype exempted_principals: list[str] + """ super(PutTenantPolicyRequestProperties, self).__init__(**kwargs) self.block_subscriptions_leaving_tenant = block_subscriptions_leaving_tenant self.block_subscriptions_into_tenant = block_subscriptions_into_tenant @@ -639,6 +762,8 @@ def __init__( self, **kwargs ): + """ + """ super(RenamedSubscriptionId, self).__init__(**kwargs) self.value = None @@ -646,10 +771,10 @@ def __init__( 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 + :ivar tenant_id: Service tenant id. + :vartype tenant_id: str + :ivar tenant_name: Service tenant name. + :vartype tenant_name: str """ _attribute_map = { @@ -664,6 +789,12 @@ def __init__( tenant_name: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: Service tenant id. + :paramtype tenant_id: str + :keyword tenant_name: Service tenant name. + :paramtype tenant_name: str + """ super(ServiceTenantResponse, self).__init__(**kwargs) self.tenant_id = tenant_id self.tenant_name = tenant_name @@ -694,6 +825,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionAliasListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -710,8 +843,8 @@ class SubscriptionAliasResponse(msrest.serialization.Model): :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 properties: Subscription Alias response properties. + :vartype 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 """ @@ -737,6 +870,10 @@ def __init__( properties: Optional["SubscriptionAliasResponseProperties"] = None, **kwargs ): + """ + :keyword properties: Subscription Alias response properties. + :paramtype properties: ~azure.mgmt.subscription.models.SubscriptionAliasResponseProperties + """ super(SubscriptionAliasResponse, self).__init__(**kwargs) self.id = None self.name = None @@ -752,34 +889,34 @@ class SubscriptionAliasResponseProperties(msrest.serialization.Model): :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: + :ivar display_name: The display name of the subscription. + :vartype display_name: str + :ivar provisioning_state: The provisioning state of the resource. Possible values include: "Accepted", "Succeeded", "Failed". - :type provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState + :vartype 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. + :ivar 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. + :vartype billing_scope: str + :ivar 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] + :vartype workload: str or ~azure.mgmt.subscription.models.Workload + :ivar reseller_id: Reseller Id. + :vartype reseller_id: str + :ivar subscription_owner_id: Owner Id of the subscription. + :vartype subscription_owner_id: str + :ivar management_group_id: The Management Group Id. + :vartype management_group_id: str + :ivar tags: A set of tags. Tags for the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -815,6 +952,31 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword display_name: The display name of the subscription. + :paramtype display_name: str + :keyword provisioning_state: The provisioning state of the resource. Possible values include: + "Accepted", "Succeeded", "Failed". + :paramtype provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState + :keyword 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}. + :paramtype billing_scope: str + :keyword workload: The workload type of the subscription. It can be either Production or + DevTest. Possible values include: "Production", "DevTest". + :paramtype workload: str or ~azure.mgmt.subscription.models.Workload + :keyword reseller_id: Reseller Id. + :paramtype reseller_id: str + :keyword subscription_owner_id: Owner Id of the subscription. + :paramtype subscription_owner_id: str + :keyword management_group_id: The Management Group Id. + :paramtype management_group_id: str + :keyword tags: A set of tags. Tags for the subscription. + :paramtype tags: dict[str, str] + """ super(SubscriptionAliasResponseProperties, self).__init__(**kwargs) self.subscription_id = None self.display_name = display_name @@ -832,8 +994,8 @@ def __init__( class SubscriptionName(msrest.serialization.Model): """The new name of the subscription. - :param subscription_name: New subscription name. - :type subscription_name: str + :ivar subscription_name: New subscription name. + :vartype subscription_name: str """ _attribute_map = { @@ -846,6 +1008,10 @@ def __init__( subscription_name: Optional[str] = None, **kwargs ): + """ + :keyword subscription_name: New subscription name. + :paramtype subscription_name: str + """ super(SubscriptionName, self).__init__(**kwargs) self.subscription_name = subscription_name @@ -853,20 +1019,20 @@ def __init__( 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 + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar 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 + :vartype last_modified_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -889,6 +1055,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.subscription.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -905,15 +1087,14 @@ class TenantPolicy(msrest.serialization.Model): :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 + :ivar block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's tenant. - :type block_subscriptions_into_tenant: bool - :param exempted_principals: List of user objectIds that are exempted from the set subscription + :vartype block_subscriptions_leaving_tenant: bool + :ivar block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's tenant. + :vartype block_subscriptions_into_tenant: bool + :ivar 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] + :vartype exempted_principals: list[str] """ _validation = { @@ -935,6 +1116,17 @@ def __init__( exempted_principals: Optional[List[str]] = None, **kwargs ): + """ + :keyword block_subscriptions_leaving_tenant: Blocks the leaving of subscriptions from user's + tenant. + :paramtype block_subscriptions_leaving_tenant: bool + :keyword block_subscriptions_into_tenant: Blocks the entering of subscriptions into user's + tenant. + :paramtype block_subscriptions_into_tenant: bool + :keyword exempted_principals: List of user objectIds that are exempted from the set + subscription tenant policies for the user's tenant. + :paramtype exempted_principals: list[str] + """ super(TenantPolicy, self).__init__(**kwargs) self.policy_id = None self.block_subscriptions_leaving_tenant = block_subscriptions_leaving_tenant 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 d413f46c84589..9fefe2b82221e 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 @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AcceptOwnership(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AcceptOwnership(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The accept ownership state of the resource. """ @@ -34,7 +19,7 @@ class AcceptOwnership(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" EXPIRED = "Expired" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -43,7 +28,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the resource. """ @@ -51,7 +36,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class Workload(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +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/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py index 4e2e789af475e..f44f6d96e7a14 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 @@ -5,24 +5,154 @@ # 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 functools +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + alias_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + path_format_arguments = { + "aliasName": _SERIALIZER.url("alias_name", alias_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + alias_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + path_format_arguments = { + "aliasName": _SERIALIZER.url("alias_name", alias_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + alias_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + path_format_arguments = { + "aliasName": _SERIALIZER.url("alias_name", alias_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AliasOperations(object): """AliasOperations operations. @@ -48,47 +178,35 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - alias_name, # type: str - body, # type: "_models.PutAliasRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionAliasResponse" + alias_name: str, + 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 = "2021-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'PutAliasRequest') - # 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') + request = build_create_request_initial( + alias_name=alias_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'PutAliasRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) @@ -100,15 +218,17 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace def begin_create( self, - alias_name, # type: str - body, # type: "_models.PutAliasRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SubscriptionAliasResponse"] + alias_name: str, + body: "_models.PutAliasRequest", + **kwargs: Any + ) -> LROPoller["_models.SubscriptionAliasResponse"]: """Create Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this @@ -119,15 +239,20 @@ def begin_create( :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: 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. + :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 SubscriptionAliasResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] - :raises ~azure.core.exceptions.HttpResponseError: + :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 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] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -138,25 +263,21 @@ def begin_create( raw_result = self._create_initial( alias_name=alias_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -168,14 +289,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + @distributed_trace def get( self, - alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionAliasResponse" + alias_name: str, + **kwargs: Any + ) -> "_models.SubscriptionAliasResponse": """Get Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this @@ -192,31 +314,21 @@ def get( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + alias_name=alias_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionAliasResponse', pipeline_response) @@ -225,14 +337,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace def delete( self, - alias_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + alias_name: str, + **kwargs: Any + ) -> None: """Delete Alias. :param alias_name: AliasName is the name for the subscription creation request. Note that this @@ -249,31 +363,21 @@ def delete( 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.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + alias_name=alias_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -281,11 +385,12 @@ def delete( delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionAliasListResult" + **kwargs: Any + ) -> "_models.SubscriptionAliasListResult": """List Alias Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -298,27 +403,20 @@ def list( 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.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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionAliasListResult', pipeline_response) @@ -327,4 +425,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore + 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 index 2b5a7b75ccca5..3740653f500ea 100644 --- 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 @@ -5,22 +5,55 @@ # 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 functools +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_policy_request( + billing_account_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingAccountOperations(object): """BillingAccountOperations operations. @@ -44,12 +77,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_policy( self, - billing_account_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingAccountPoliciesResponse" + billing_account_id: str, + **kwargs: Any + ) -> "_models.BillingAccountPoliciesResponse": """Get Billing Account Policy. :param billing_account_id: Billing Account Id. @@ -64,31 +97,21 @@ def get_policy( 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') + + request = build_get_policy_request( + billing_account_id=billing_account_id, + template_url=self.get_policy.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingAccountPoliciesResponse', pipeline_response) @@ -97,4 +120,6 @@ def get_policy( 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 1ca2ebb5cd7da..bf46f32017770 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 @@ -5,23 +5,50 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _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]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> 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 @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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 c08b23165ca34..e796b81f923b1 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 @@ -5,24 +5,200 @@ # 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 functools +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_cancel_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_rename_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_enable_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_accept_ownership_request_initial( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_accept_ownership_status_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SubscriptionOperations(object): """SubscriptionOperations operations. @@ -46,12 +222,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def cancel( self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CanceledSubscriptionId" + subscription_id: str, + **kwargs: Any + ) -> "_models.CanceledSubscriptionId": """The operation to cancel a subscription. :param subscription_id: Subscription Id. @@ -66,31 +242,21 @@ def cancel( 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.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + subscription_id=subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CanceledSubscriptionId', pipeline_response) @@ -99,15 +265,17 @@ def cancel( return cls(pipeline_response, deserialized, {}) return deserialized + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + + @distributed_trace def rename( self, - subscription_id, # type: str - body, # type: "_models.SubscriptionName" - **kwargs # type: Any - ): - # type: (...) -> "_models.RenamedSubscriptionId" + subscription_id: str, + body: "_models.SubscriptionName", + **kwargs: Any + ) -> "_models.RenamedSubscriptionId": """The operation to rename a subscription. :param subscription_id: Subscription Id. @@ -124,36 +292,26 @@ def rename( 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.rename.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(body, 'SubscriptionName') + + request = build_rename_request( + subscription_id=subscription_id, + content_type=content_type, + json=_json, + template_url=self.rename.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'SubscriptionName') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RenamedSubscriptionId', pipeline_response) @@ -162,14 +320,16 @@ def rename( return cls(pipeline_response, deserialized, {}) return deserialized + rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + + @distributed_trace def enable( self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EnabledSubscriptionId" + subscription_id: str, + **kwargs: Any + ) -> "_models.EnabledSubscriptionId": """The operation to enable a subscription. :param subscription_id: Subscription Id. @@ -184,31 +344,21 @@ def enable( 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.enable.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_enable_request( + subscription_id=subscription_id, + template_url=self.enable.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnabledSubscriptionId', pipeline_response) @@ -217,68 +367,60 @@ def enable( return cls(pipeline_response, deserialized, {}) 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 + 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(body, 'AcceptOwnershipRequest') + + request = build_accept_ownership_request_initial( + subscription_id=subscription_id, + content_type=content_type, + json=_json, + template_url=self._accept_ownership_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + raise HttpResponseError(response=response, 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 + + @distributed_trace def begin_accept_ownership( self, - subscription_id, # type: str - body, # type: "_models.AcceptOwnershipRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + subscription_id: str, + body: "_models.AcceptOwnershipRequest", + **kwargs: Any + ) -> LROPoller[None]: """Accept subscription ownership. :param subscription_id: Subscription Id. @@ -287,15 +429,18 @@ def begin_accept_ownership( :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. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -306,22 +451,18 @@ def begin_accept_ownership( raw_result = self._accept_ownership_initial( subscription_id=subscription_id, body=body, + content_type=content_type, 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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -333,14 +474,15 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace def accept_ownership_status( self, - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AcceptOwnershipStatusResponse" + subscription_id: str, + **kwargs: Any + ) -> "_models.AcceptOwnershipStatusResponse": """Accept subscription ownership status. :param subscription_id: Subscription Id. @@ -355,31 +497,21 @@ def accept_ownership_status( 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 = build_accept_ownership_status_request( + subscription_id=subscription_id, + template_url=self.accept_ownership_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AcceptOwnershipStatusResponse', pipeline_response) @@ -388,4 +520,6 @@ def accept_ownership_status( 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/_subscription_policy_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py index d023d1160ba87..e58bc9b01a719 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_policy_operations.py @@ -5,23 +5,110 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _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]] +from .._vendor import _convert_request +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_add_update_policy_for_tenant_request( + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies/default') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_policy_for_tenant_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies/default') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_policy_for_tenant_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SubscriptionPolicyOperations(object): """SubscriptionPolicyOperations operations. @@ -45,12 +132,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def add_update_policy_for_tenant( self, - body, # type: "_models.PutTenantPolicyRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.GetTenantPolicyResponse" + body: "_models.PutTenantPolicyRequestProperties", + **kwargs: Any + ) -> "_models.GetTenantPolicyResponse": """Create or Update Subscription tenant policy for user's tenant. :param body: @@ -65,32 +152,25 @@ def add_update_policy_for_tenant( 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.add_update_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') - - # 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, 'PutTenantPolicyRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(body, 'PutTenantPolicyRequestProperties') + + request = build_add_update_policy_for_tenant_request( + content_type=content_type, + json=_json, + template_url=self.add_update_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) @@ -99,13 +179,15 @@ def add_update_policy_for_tenant( return cls(pipeline_response, deserialized, {}) return deserialized + add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + + @distributed_trace def get_policy_for_tenant( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.GetTenantPolicyResponse" + **kwargs: Any + ) -> "_models.GetTenantPolicyResponse": """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 @@ -118,27 +200,20 @@ def get_policy_for_tenant( 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_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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_policy_for_tenant_request( + template_url=self.get_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GetTenantPolicyResponse', pipeline_response) @@ -147,18 +222,22 @@ def get_policy_for_tenant( return cls(pipeline_response, deserialized, {}) return deserialized + get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + + @distributed_trace def list_policy_for_tenant( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GetTenantPolicyListResponse"] + **kwargs: Any + ) -> 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 GetTenantPolicyListResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] + :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.GetTenantPolicyListResponse"] @@ -166,30 +245,27 @@ def list_policy_for_tenant( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-10-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_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') + + request = build_list_policy_for_tenant_request( + template_url=self.list_policy_for_tenant.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_policy_for_tenant_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GetTenantPolicyListResponse', pipeline_response) + deserialized = self._deserialize("GetTenantPolicyListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -202,12 +278,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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseBody, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )