From a056d0457c2de1db60c4e945d955f4caabee4f95 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 25 Jul 2022 07:25:45 +0000 Subject: [PATCH] CodeGen from PR 19919 in Azure/azure-rest-api-specs Merge afb1247889ecba5ede45bea6bdec72867f16df9f into a211ef525cdd9e186f31b5c11647aae31dccc469 --- .../azure-mgmt-subscription/_meta.json | 6 +- .../azure/mgmt/subscription/__init__.py | 13 +- .../azure/mgmt/subscription/_configuration.py | 2 +- .../azure/mgmt/subscription/_metadata.json | 96 ----- .../mgmt/subscription/_subscription_client.py | 39 +- .../azure/mgmt/subscription/_version.py | 2 +- .../azure/mgmt/subscription/aio/__init__.py | 13 +- .../mgmt/subscription/aio/_configuration.py | 2 +- .../subscription/aio/_subscription_client.py | 37 +- .../subscription/aio/operations/__init__.py | 5 + .../aio/operations/_alias_operations.py | 180 ++++++--- .../operations/_billing_account_operations.py | 61 ++-- .../aio/operations/_operations.py | 67 ++-- .../subscription/aio/operations/_patch.py | 19 + .../operations/_subscription_operations.py | 207 +++++++---- .../_subscription_policy_operations.py | 123 +++++-- .../operations/_subscriptions_operations.py | 125 +++++-- .../aio/operations/_tenants_operations.py | 67 ++-- .../mgmt/subscription/models/__init__.py | 6 +- .../mgmt/subscription/models/_models_py3.py | 132 ++++--- .../azure/mgmt/subscription/models/_patch.py | 19 + .../models/_subscription_client_enums.py | 13 +- .../mgmt/subscription/operations/__init__.py | 5 + .../operations/_alias_operations.py | 285 +++++++++------ .../operations/_billing_account_operations.py | 90 +++-- .../subscription/operations/_operations.py | 93 +++-- .../mgmt/subscription/operations/_patch.py | 19 + .../operations/_subscription_operations.py | 343 +++++++++++------- .../_subscription_policy_operations.py | 200 ++++++---- .../operations/_subscriptions_operations.py | 200 ++++++---- .../operations/_tenants_operations.py | 93 +++-- 31 files changed, 1611 insertions(+), 951 deletions(-) delete mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_patch.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_patch.py create mode 100644 sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_patch.py diff --git a/sdk/subscription/azure-mgmt-subscription/_meta.json b/sdk/subscription/azure-mgmt-subscription/_meta.json index 26df39e60ba6..187f4fb3a041 100644 --- a/sdk/subscription/azure-mgmt-subscription/_meta.json +++ b/sdk/subscription/azure-mgmt-subscription/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "1b0a465061c68175898f8f5d27f0301f42ce994c", + "commit": "e5d213cd9a55f4a0c51050eb42d4f2c7f59f3180", "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 --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/subscription/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.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 abd8e21f3338..294cb5dfd882 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['SubscriptionClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_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 cb1f8cba0c58..090c7a8813d7 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class SubscriptionClientConfiguration(Configuration): +class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SubscriptionClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json deleted file mode 100644 index d95fe0c700f0..000000000000 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_metadata.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "chosen_version": "", - "total_api_version_list": ["2016-06-01", "2021-10-01"], - "client": { - "name": "SubscriptionClient", - "filename": "_subscription_client", - "description": "The subscription client.", - "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\"]}}}", - "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": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_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": { - "subscriptions": "SubscriptionsOperations", - "tenants": "TenantsOperations", - "subscription": "SubscriptionOperations", - "operations": "Operations", - "alias": "AliasOperations", - "subscription_policy": "SubscriptionPolicyOperations", - "billing_account": "BillingAccountOperations" - } -} \ No newline at end of file diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py index 13c065de0704..a5e3d6befc00 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer 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 @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SubscriptionClient: +class SubscriptionClient: # pylint: disable=too-many-instance-attributes """The subscription client. :ivar subscriptions: SubscriptionsOperations operations @@ -40,7 +41,7 @@ class SubscriptionClient: :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 base_url: Service URL. Default value is 'https://management.azure.com'. + :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. @@ -59,18 +60,32 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.alias = AliasOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_policy = SubscriptionPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.billing_account = BillingAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenants = TenantsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_policy = SubscriptionPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.billing_account = BillingAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. 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 cac9f5d10f8b..e5754a47ce68 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 = "3.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 e95939087d44..3671b7c5ef25 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._subscription_client import SubscriptionClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['SubscriptionClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_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 a7b3afad9470..9b31ad7079a7 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClientConfiguration(Configuration): +class SubscriptionClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SubscriptionClient. Note that all parameters used to create this instance are saved as instance 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 b8dcc9114fa8..29bf57ab523f 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer 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 @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SubscriptionClient: +class SubscriptionClient: # pylint: disable=too-many-instance-attributes """The subscription client. :ivar subscriptions: SubscriptionsOperations operations @@ -41,7 +42,7 @@ class SubscriptionClient: :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 base_url: Service URL. Default value is 'https://management.azure.com'. + :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. @@ -60,13 +61,27 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.alias = AliasOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_policy = SubscriptionPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.billing_account = BillingAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenants = TenantsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alias = AliasOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_policy = SubscriptionPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.billing_account = BillingAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py index 502c2c8aa6d2..e772d47981c4 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._subscription_policy_operations import SubscriptionPolicyOperations from ._billing_account_operations import BillingAccountOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SubscriptionsOperations', 'TenantsOperations', @@ -23,3 +26,5 @@ 'SubscriptionPolicyOperations', 'BillingAccountOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 a126f0cc5f6c..abf08635bdc1 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,6 +14,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -25,53 +25,62 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AliasOperations: - """AliasOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`alias` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, alias_name: str, - body: "_models.PutAliasRequest", + body: _models.PutAliasRequest, **kwargs: Any - ) -> "_models.SubscriptionAliasResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] + ) -> _models.SubscriptionAliasResponse: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] _json = self._serialize.body(body, 'PutAliasRequest') request = build_create_request_initial( alias_name=alias_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -89,16 +98,16 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + _create_initial.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace_async async def begin_create( self, alias_name: str, - body: "_models.PutAliasRequest", + body: _models.PutAliasRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.SubscriptionAliasResponse"]: + ) -> AsyncLROPoller[_models.SubscriptionAliasResponse]: """Create Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this @@ -107,6 +116,9 @@ async def begin_create( :type alias_name: str :param body: :type body: ~azure.mgmt.subscription.models.PutAliasRequest + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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 @@ -121,34 +133,46 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - 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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore alias_name=alias_name, body=body, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -157,43 +181,57 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + begin_create.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace_async async def get( self, alias_name: str, **kwargs: Any - ) -> "_models.SubscriptionAliasResponse": + ) -> _models.SubscriptionAliasResponse: """Get Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. :type alias_name: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionAliasResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] request = build_get_request( alias_name=alias_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -208,11 +246,11 @@ async def get( return deserialized - get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, alias_name: str, **kwargs: Any @@ -223,26 +261,41 @@ async def delete( is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. :type alias_name: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( alias_name=alias_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -253,35 +306,50 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace_async async def list( self, **kwargs: Any - ) -> "_models.SubscriptionAliasListResult": + ) -> _models.SubscriptionAliasListResult: """List Alias Subscription. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionAliasListResult, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasListResult] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -296,5 +364,5 @@ async def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore + 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 00f1cc1f156b..aeb044ea7b0a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,57 +23,70 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BillingAccountOperations: - """BillingAccountOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`billing_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_policy( self, billing_account_id: str, **kwargs: Any - ) -> "_models.BillingAccountPoliciesResponse": + ) -> _models.BillingAccountPoliciesResponse: """Get Billing Account Policy. :param billing_account_id: Billing Account Id. :type billing_account_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BillingAccountPoliciesResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccountPoliciesResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BillingAccountPoliciesResponse] request = build_get_policy_request( billing_account_id=billing_account_id, + api_version=api_version, template_url=self.get_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,5 +101,5 @@ async def get_policy( return deserialized - get_policy.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default'} # type: ignore + 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 50b190fe7e74..47575e5797dd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,61 +24,73 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Microsoft.Subscription API operations. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,4 +122,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Subscription/operations"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_patch.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 b09962e5145c..58560241274c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,6 +14,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -25,57 +25,70 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionOperations: - """SubscriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def cancel( self, subscription_id: str, **kwargs: Any - ) -> "_models.CanceledSubscriptionId": + ) -> _models.CanceledSubscriptionId: """The operation to cancel a subscription. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CanceledSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CanceledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CanceledSubscriptionId] request = build_cancel_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.cancel.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,47 +103,61 @@ async def cancel( return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + cancel.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel"} # type: ignore @distributed_trace_async async def rename( self, subscription_id: str, - body: "_models.SubscriptionName", + body: _models.SubscriptionName, **kwargs: Any - ) -> "_models.RenamedSubscriptionId": + ) -> _models.RenamedSubscriptionId: """The operation to rename a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :param body: Subscription Name. :type body: ~azure.mgmt.subscription.models.SubscriptionName + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RenamedSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RenamedSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RenamedSubscriptionId] _json = self._serialize.body(body, 'SubscriptionName') request = build_rename_request( subscription_id=subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.rename.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,7 +172,7 @@ async def rename( return deserialized - rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + rename.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename"} # type: ignore @distributed_trace_async @@ -153,31 +180,46 @@ async def enable( self, subscription_id: str, **kwargs: Any - ) -> "_models.EnabledSubscriptionId": + ) -> _models.EnabledSubscriptionId: """The operation to enable a subscription. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EnabledSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnabledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EnabledSubscriptionId] request = build_enable_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.enable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,35 +234,46 @@ async def enable( return deserialized - enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + enable.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable"} # type: ignore - async def _accept_ownership_initial( + async def _accept_ownership_initial( # pylint: disable=inconsistent-return-statements self, subscription_id: str, - body: "_models.AcceptOwnershipRequest", + 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(body, 'AcceptOwnershipRequest') request = build_accept_ownership_request_initial( subscription_id=subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._accept_ownership_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -235,14 +288,14 @@ async def _accept_ownership_initial( if cls: return cls(pipeline_response, None, response_headers) - _accept_ownership_initial.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership'} # type: ignore + _accept_ownership_initial.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership"} # type: ignore @distributed_trace_async - async def begin_accept_ownership( + async def begin_accept_ownership( # pylint: disable=inconsistent-return-statements self, subscription_id: str, - body: "_models.AcceptOwnershipRequest", + body: _models.AcceptOwnershipRequest, **kwargs: Any ) -> AsyncLROPoller[None]: """Accept subscription ownership. @@ -251,6 +304,9 @@ async def begin_accept_ownership( :type subscription_id: str :param body: :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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 @@ -263,20 +319,27 @@ async def begin_accept_ownership( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._accept_ownership_initial( + raw_result = await self._accept_ownership_initial( # type: ignore subscription_id=subscription_id, body=body, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -286,8 +349,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -296,41 +365,55 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_accept_ownership.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership'} # type: ignore + begin_accept_ownership.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership"} # type: ignore @distributed_trace_async async def accept_ownership_status( self, subscription_id: str, **kwargs: Any - ) -> "_models.AcceptOwnershipStatusResponse": + ) -> _models.AcceptOwnershipStatusResponse: """Accept subscription ownership status. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AcceptOwnershipStatusResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.AcceptOwnershipStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AcceptOwnershipStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AcceptOwnershipStatusResponse] request = build_accept_ownership_status_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.accept_ownership_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -345,5 +428,5 @@ async def accept_ownership_status( return deserialized - accept_ownership_status.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus'} # type: ignore + accept_ownership_status.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{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 ec61ddffa393..d2f4f99b215d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,61 +25,73 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionPolicyOperations: - """SubscriptionPolicyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`subscription_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def add_update_policy_for_tenant( self, - body: "_models.PutTenantPolicyRequestProperties", + body: _models.PutTenantPolicyRequestProperties, **kwargs: Any - ) -> "_models.GetTenantPolicyResponse": + ) -> _models.GetTenantPolicyResponse: """Create or Update Subscription tenant policy for user's tenant. :param body: :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GetTenantPolicyResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyResponse] _json = self._serialize.body(body, 'PutTenantPolicyRequestProperties') request = build_add_update_policy_for_tenant_request( + api_version=api_version, content_type=content_type, json=_json, template_url=self.add_update_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,35 +106,50 @@ async def add_update_policy_for_tenant( return deserialized - add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + 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 - ) -> "_models.GetTenantPolicyResponse": + ) -> _models.GetTenantPolicyResponse: """Get the subscription tenant policy for the user's tenant. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GetTenantPolicyResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyResponse] request = build_get_policy_for_tenant_request( + api_version=api_version, template_url=self.get_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,16 +164,19 @@ async def get_policy_for_tenant( return deserialized - get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + get_policy_for_tenant.metadata = {'url': "/providers/Microsoft.Subscription/policies/default"} # type: ignore @distributed_trace def list_policy_for_tenant( self, **kwargs: Any - ) -> AsyncIterable["_models.GetTenantPolicyListResponse"]: + ) -> AsyncIterable[_models.GetTenantPolicyListResponse]: """Get the subscription tenant policy for the user's tenant. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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) @@ -154,27 +184,38 @@ def list_policy_for_tenant( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyListResponse"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyListResponse] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_policy_for_tenant_request( + api_version=api_version, template_url=self.list_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_policy_for_tenant_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -188,7 +229,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,4 +247,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies'} # type: ignore + list_policy_for_tenant.metadata = {'url': "/providers/Microsoft.Subscription/policies"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py index c5f432b6852f..d81ca5c6b1a5 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionsOperations: - """SubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_locations( self, subscription_id: str, **kwargs: Any - ) -> AsyncIterable["_models.LocationListResult"]: + ) -> AsyncIterable[_models.LocationListResult]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, @@ -59,35 +57,49 @@ def list_locations( :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_locations_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.list_locations.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_locations_request( subscription_id=subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +113,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,38 +130,53 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace_async async def get( self, subscription_id: str, **kwargs: Any - ) -> "_models.Subscription": + ) -> _models.Subscription: """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Subscription, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.Subscription :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Subscription] request = build_get_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,16 +190,19 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionListResult"]: + ) -> AsyncIterable[_models.SubscriptionListResult]: """Gets all subscriptions for a tenant. + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) @@ -176,27 +210,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -210,7 +255,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,4 +272,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py index 534ac5fdbe1c..80d3aa391509 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/aio/operations/_tenants_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,61 +24,73 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantsOperations: - """TenantsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.aio.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.TenantListResult"]: + ) -> AsyncIterable[_models.TenantListResult]: """Gets the tenants for your account. + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.subscription.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/tenants'} # type: ignore + list.metadata = {'url': "/tenants"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/__init__.py index 278a7e1ddf02..093ba9caeebe 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 @@ -49,7 +49,9 @@ SubscriptionState, Workload, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AcceptOwnershipRequest', 'AcceptOwnershipRequestProperties', @@ -91,3 +93,5 @@ 'SubscriptionState', 'Workload', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 85bfda0fa46b..44e18e8853de 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._subscription_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AcceptOwnershipRequest(msrest.serialization.Model): @@ -29,7 +31,7 @@ class AcceptOwnershipRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["AcceptOwnershipRequestProperties"] = None, + properties: Optional["_models.AcceptOwnershipRequestProperties"] = None, **kwargs ): """ @@ -92,8 +94,8 @@ class AcceptOwnershipStatusResponse(msrest.serialization.Model): :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". + :ivar accept_ownership_state: The accept ownership state of the resource. Known values are: + "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 @@ -180,7 +182,7 @@ class BillingAccountPoliciesResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["BillingAccountPoliciesResponseProperties"] = None, + properties: Optional["_models.BillingAccountPoliciesResponseProperties"] = None, **kwargs ): """ @@ -212,7 +214,7 @@ class BillingAccountPoliciesResponseProperties(msrest.serialization.Model): def __init__( self, *, - service_tenants: Optional[List["ServiceTenantResponse"]] = None, + service_tenants: Optional[List["_models.ServiceTenantResponse"]] = None, allow_transfers: Optional[bool] = None, **kwargs ): @@ -333,7 +335,7 @@ class ErrorResponseBody(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, code: Optional[str] = None, message: Optional[str] = None, **kwargs @@ -419,7 +421,7 @@ class GetTenantPolicyResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["TenantPolicy"] = None, + properties: Optional["_models.TenantPolicy"] = None, **kwargs ): """ @@ -501,7 +503,7 @@ class LocationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Location"]] = None, + value: Optional[List["_models.Location"]] = None, **kwargs ): """ @@ -534,7 +536,7 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -614,7 +616,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -643,7 +645,7 @@ class PutAliasRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["PutAliasRequestProperties"] = None, + properties: Optional["_models.PutAliasRequestProperties"] = None, **kwargs ): """ @@ -706,7 +708,7 @@ class PutAliasRequestProperties(msrest.serialization.Model): :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". + Known values are: "Production", "DevTest". :vartype workload: str or ~azure.mgmt.subscription.models.Workload :ivar billing_scope: Billing scope of the subscription. For CustomerLed and FieldLed - @@ -737,18 +739,18 @@ def __init__( self, *, display_name: Optional[str] = None, - workload: Optional[Union[str, "Workload"]] = None, + workload: Optional[Union[str, "_models.Workload"]] = None, billing_scope: Optional[str] = None, subscription_id: Optional[str] = None, reseller_id: Optional[str] = None, - additional_properties: Optional["PutAliasRequestAdditionalProperties"] = None, + additional_properties: Optional["_models.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". + DevTest. Known values are: "Production", "DevTest". :paramtype workload: str or ~azure.mgmt.subscription.models.Workload :keyword billing_scope: Billing scope of the subscription. For CustomerLed and FieldLed - @@ -891,7 +893,7 @@ class Subscription(msrest.serialization.Model): :ivar display_name: The subscription display name. :vartype display_name: str :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, - and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". + and Deleted. Known values are: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.subscription.models.SubscriptionState :ivar subscription_policies: The subscription policies. :vartype subscription_policies: ~azure.mgmt.subscription.models.SubscriptionPolicies @@ -920,7 +922,7 @@ class Subscription(msrest.serialization.Model): def __init__( self, *, - subscription_policies: Optional["SubscriptionPolicies"] = None, + subscription_policies: Optional["_models.SubscriptionPolicies"] = None, authorization_source: Optional[str] = None, **kwargs ): @@ -1008,7 +1010,7 @@ class SubscriptionAliasResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["SubscriptionAliasResponseProperties"] = None, + properties: Optional["_models.SubscriptionAliasResponseProperties"] = None, **kwargs ): """ @@ -1032,13 +1034,13 @@ class SubscriptionAliasResponseProperties(msrest.serialization.Model): :vartype subscription_id: str :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". + :ivar provisioning_state: The provisioning state of the resource. Known values are: "Accepted", + "Succeeded", "Failed". :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". + :ivar accept_ownership_state: The accept ownership state of the resource. Known values are: + "Pending", "Completed", "Expired". :vartype accept_ownership_state: str or ~azure.mgmt.subscription.models.AcceptOwnership :ivar billing_scope: Billing scope of the subscription. For CustomerLed and FieldLed - @@ -1048,7 +1050,7 @@ class SubscriptionAliasResponseProperties(msrest.serialization.Model): /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName}. :vartype billing_scope: str :ivar workload: The workload type of the subscription. It can be either Production or DevTest. - Possible values include: "Production", "DevTest". + Known values are: "Production", "DevTest". :vartype workload: str or ~azure.mgmt.subscription.models.Workload :ivar reseller_id: Reseller Id. :vartype reseller_id: str @@ -1087,9 +1089,9 @@ def __init__( self, *, display_name: Optional[str] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, billing_scope: Optional[str] = None, - workload: Optional[Union[str, "Workload"]] = None, + workload: Optional[Union[str, "_models.Workload"]] = None, reseller_id: Optional[str] = None, subscription_owner_id: Optional[str] = None, management_group_id: Optional[str] = None, @@ -1100,7 +1102,7 @@ def __init__( """ :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: + :keyword provisioning_state: The provisioning state of the resource. Known values are: "Accepted", "Succeeded", "Failed". :paramtype provisioning_state: str or ~azure.mgmt.subscription.models.ProvisioningState :keyword billing_scope: Billing scope of the subscription. @@ -1111,7 +1113,7 @@ def __init__( /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". + DevTest. Known values are: "Production", "DevTest". :paramtype workload: str or ~azure.mgmt.subscription.models.Workload :keyword reseller_id: Reseller Id. :paramtype reseller_id: str @@ -1142,18 +1144,12 @@ def __init__( class SubscriptionListResult(msrest.serialization.Model): """Subscription list operation response. - All required parameters must be populated in order to send to Azure. - :ivar value: An array of subscriptions. :vartype value: list[~azure.mgmt.subscription.models.Subscription] - :ivar next_link: Required. The URL to get the next set of results. + :ivar next_link: The URL to get the next set of results. :vartype next_link: str """ - _validation = { - 'next_link': {'required': True}, - } - _attribute_map = { 'value': {'key': 'value', 'type': '[Subscription]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, @@ -1162,14 +1158,14 @@ class SubscriptionListResult(msrest.serialization.Model): def __init__( self, *, - next_link: str, - value: Optional[List["Subscription"]] = None, + value: Optional[List["_models.Subscription"]] = None, + next_link: Optional[str] = None, **kwargs ): """ :keyword value: An array of subscriptions. :paramtype value: list[~azure.mgmt.subscription.models.Subscription] - :keyword next_link: Required. The URL to get the next set of results. + :keyword next_link: The URL to get the next set of results. :paramtype next_link: str """ super(SubscriptionListResult, self).__init__(**kwargs) @@ -1213,7 +1209,7 @@ class SubscriptionPolicies(msrest.serialization.Model): :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + :ivar spending_limit: The subscription spending limit. Known values are: "On", "Off", "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.subscription.models.SpendingLimit """ @@ -1247,15 +1243,15 @@ class SystemData(msrest.serialization.Model): :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: + :ivar created_by_type: The type of identity that created the resource. Known values are: "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". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :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 @@ -1274,25 +1270,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, 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". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "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". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "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 @@ -1316,16 +1312,45 @@ class TenantIdDescription(msrest.serialization.Model): :vartype id: str :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str + :ivar tenant_category: The category of the tenant. Possible values are + TenantCategoryHome,TenantCategoryProjectedBy,TenantCategoryManagedBy. + :vartype tenant_category: str + :ivar country: The country/region name of the address for the tenant. + :vartype country: str + :ivar country_code: The Country/region abbreviation for the tenant. + :vartype country_code: str + :ivar display_name: The display name of the tenant. + :vartype display_name: str + :ivar domains: The list of domains for the tenant. + :vartype domains: str + :ivar default_domain: The default domain for the tenant. + :vartype default_domain: str + :ivar tenant_type: The tenant type. Only available for Home tenant category. + :vartype tenant_type: str """ _validation = { 'id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'tenant_category': {'readonly': True}, + 'country': {'readonly': True}, + 'country_code': {'readonly': True}, + 'display_name': {'readonly': True}, + 'domains': {'readonly': True}, + 'default_domain': {'readonly': True}, + 'tenant_type': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, + 'country': {'key': 'country', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'domains': {'key': 'domains', 'type': 'str'}, + 'default_domain': {'key': 'defaultDomain', 'type': 'str'}, + 'tenant_type': {'key': 'tenantType', 'type': 'str'}, } def __init__( @@ -1337,6 +1362,13 @@ def __init__( super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None + self.tenant_category = None + self.country = None + self.country_code = None + self.display_name = None + self.domains = None + self.default_domain = None + self.tenant_type = None class TenantListResult(msrest.serialization.Model): @@ -1363,7 +1395,7 @@ def __init__( self, *, next_link: str, - value: Optional[List["TenantIdDescription"]] = None, + value: Optional[List["_models.TenantIdDescription"]] = None, **kwargs ): """ diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_patch.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 7f4f5b951afe..9b3bc94e4aa9 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 @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AcceptOwnership(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AcceptOwnership(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The accept ownership state of the resource. """ @@ -19,7 +18,7 @@ class AcceptOwnership(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" EXPIRED = "Expired" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -28,7 +27,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the resource. """ @@ -36,7 +35,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The subscription spending limit. """ @@ -44,7 +43,7 @@ class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ @@ -54,7 +53,7 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class Workload(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Workload(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The workload type of the subscription. It can be either Production or DevTest. """ diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py index 502c2c8aa6d2..e772d47981c4 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py @@ -14,6 +14,9 @@ from ._subscription_policy_operations import SubscriptionPolicyOperations from ._billing_account_operations import BillingAccountOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SubscriptionsOperations', 'TenantsOperations', @@ -23,3 +26,5 @@ 'SubscriptionPolicyOperations', 'BillingAccountOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 f44f6d96e7a1..b9d501e85f3f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,14 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict 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 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() @@ -31,37 +31,38 @@ def build_create_request_initial( alias_name: str, *, - json: JSONType = None, + json: Optional[_models.PutAliasRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + _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) + _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -72,29 +73,31 @@ def build_get_request( alias_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + _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) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -103,29 +106,31 @@ def build_delete_request( alias_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases/{aliasName}') + _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) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -133,75 +138,86 @@ def build_delete_request( def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/aliases') + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AliasOperations(object): - """AliasOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AliasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`alias` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, alias_name: str, - body: "_models.PutAliasRequest", + body: _models.PutAliasRequest, **kwargs: Any - ) -> "_models.SubscriptionAliasResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] + ) -> _models.SubscriptionAliasResponse: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] _json = self._serialize.body(body, 'PutAliasRequest') request = build_create_request_initial( alias_name=alias_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -219,16 +235,16 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + _create_initial.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace def begin_create( self, alias_name: str, - body: "_models.PutAliasRequest", + body: _models.PutAliasRequest, **kwargs: Any - ) -> LROPoller["_models.SubscriptionAliasResponse"]: + ) -> LROPoller[_models.SubscriptionAliasResponse]: """Create Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this @@ -237,6 +253,9 @@ def begin_create( :type alias_name: str :param body: :type body: ~azure.mgmt.subscription.models.PutAliasRequest + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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 @@ -251,34 +270,46 @@ def begin_create( ~azure.core.polling.LROPoller[~azure.mgmt.subscription.models.SubscriptionAliasResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - 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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore alias_name=alias_name, body=body, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -287,43 +318,57 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + begin_create.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace def get( self, alias_name: str, **kwargs: Any - ) -> "_models.SubscriptionAliasResponse": + ) -> _models.SubscriptionAliasResponse: """Get Alias Subscription. :param alias_name: AliasName is the name for the subscription creation request. Note that this is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. :type alias_name: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionAliasResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasResponse] request = build_get_request( alias_name=alias_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,11 +383,11 @@ def get( return deserialized - get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, alias_name: str, **kwargs: Any @@ -353,26 +398,41 @@ def delete( is not the same as subscription name and this doesn’t have any other lifecycle need beyond the request for subscription creation. :type alias_name: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( alias_name=alias_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -383,35 +443,50 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Subscription/aliases/{aliasName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> "_models.SubscriptionAliasListResult": + ) -> _models.SubscriptionAliasListResult: """List Alias Subscription. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionAliasListResult, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.SubscriptionAliasListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionAliasListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionAliasListResult] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,5 +501,5 @@ def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} # type: ignore + 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 3740653f500e..302abe146915 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -29,84 +30,99 @@ def build_get_policy_request( billing_account_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BillingAccountOperations(object): - """BillingAccountOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BillingAccountOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`billing_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_policy( self, billing_account_id: str, **kwargs: Any - ) -> "_models.BillingAccountPoliciesResponse": + ) -> _models.BillingAccountPoliciesResponse: """Get Billing Account Policy. :param billing_account_id: Billing Account Id. :type billing_account_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BillingAccountPoliciesResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.BillingAccountPoliciesResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccountPoliciesResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BillingAccountPoliciesResponse] request = build_get_policy_request( billing_account_id=billing_account_id, + api_version=api_version, template_url=self.get_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,5 +137,5 @@ def get_policy( return deserialized - get_policy.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default'} # type: ignore + 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 bf46f3201777..32f5806a5ab0 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,82 +30,96 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/operations') + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Microsoft.Subscription API operations. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +133,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +151,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Subscription/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Subscription/operations"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_patch.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 ccbb6fc08733..ccc8372e829a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,14 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict 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 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() @@ -32,29 +32,31 @@ def build_cancel_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel') + _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) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -62,37 +64,38 @@ def build_cancel_request( def build_rename_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SubscriptionName] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename') + _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) + _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -103,29 +106,31 @@ def build_enable_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable') + _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) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -133,37 +138,38 @@ def build_enable_request( def build_accept_ownership_request_initial( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AcceptOwnershipRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership') + _url = kwargs.pop("template_url", "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -174,84 +180,99 @@ def build_accept_ownership_status_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus') + _url = kwargs.pop("template_url", "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionOperations(object): - """SubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def cancel( self, subscription_id: str, **kwargs: Any - ) -> "_models.CanceledSubscriptionId": + ) -> _models.CanceledSubscriptionId: """The operation to cancel a subscription. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CanceledSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.CanceledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CanceledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CanceledSubscriptionId] request = build_cancel_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.cancel.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -266,47 +287,61 @@ def cancel( return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'} # type: ignore + cancel.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel"} # type: ignore @distributed_trace def rename( self, subscription_id: str, - body: "_models.SubscriptionName", + body: _models.SubscriptionName, **kwargs: Any - ) -> "_models.RenamedSubscriptionId": + ) -> _models.RenamedSubscriptionId: """The operation to rename a subscription. :param subscription_id: Subscription Id. :type subscription_id: str :param body: Subscription Name. :type body: ~azure.mgmt.subscription.models.SubscriptionName + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RenamedSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.RenamedSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RenamedSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RenamedSubscriptionId] _json = self._serialize.body(body, 'SubscriptionName') request = build_rename_request( subscription_id=subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.rename.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -321,7 +356,7 @@ def rename( return deserialized - rename.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'} # type: ignore + rename.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename"} # type: ignore @distributed_trace @@ -329,31 +364,46 @@ def enable( self, subscription_id: str, **kwargs: Any - ) -> "_models.EnabledSubscriptionId": + ) -> _models.EnabledSubscriptionId: """The operation to enable a subscription. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EnabledSubscriptionId, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.EnabledSubscriptionId :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnabledSubscriptionId"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EnabledSubscriptionId] request = build_enable_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.enable.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -368,35 +418,46 @@ def enable( return deserialized - enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} # type: ignore + enable.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable"} # type: ignore - def _accept_ownership_initial( + def _accept_ownership_initial( # pylint: disable=inconsistent-return-statements self, subscription_id: str, - body: "_models.AcceptOwnershipRequest", + 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(body, 'AcceptOwnershipRequest') request = build_accept_ownership_request_initial( subscription_id=subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._accept_ownership_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -411,14 +472,14 @@ def _accept_ownership_initial( if cls: return cls(pipeline_response, None, response_headers) - _accept_ownership_initial.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership'} # type: ignore + _accept_ownership_initial.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership"} # type: ignore @distributed_trace - def begin_accept_ownership( + def begin_accept_ownership( # pylint: disable=inconsistent-return-statements self, subscription_id: str, - body: "_models.AcceptOwnershipRequest", + body: _models.AcceptOwnershipRequest, **kwargs: Any ) -> LROPoller[None]: """Accept subscription ownership. @@ -427,6 +488,9 @@ def begin_accept_ownership( :type subscription_id: str :param body: :type body: ~azure.mgmt.subscription.models.AcceptOwnershipRequest + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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 @@ -439,20 +503,27 @@ def begin_accept_ownership( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._accept_ownership_initial( + raw_result = self._accept_ownership_initial( # type: ignore subscription_id=subscription_id, body=body, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -462,8 +533,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -472,41 +549,55 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_accept_ownership.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership'} # type: ignore + begin_accept_ownership.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership"} # type: ignore @distributed_trace def accept_ownership_status( self, subscription_id: str, **kwargs: Any - ) -> "_models.AcceptOwnershipStatusResponse": + ) -> _models.AcceptOwnershipStatusResponse: """Accept subscription ownership status. :param subscription_id: Subscription Id. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AcceptOwnershipStatusResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.AcceptOwnershipStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AcceptOwnershipStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AcceptOwnershipStatusResponse] request = build_accept_ownership_status_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.accept_ownership_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,5 +612,5 @@ def accept_ownership_status( return deserialized - accept_ownership_status.metadata = {'url': '/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus'} # type: ignore + accept_ownership_status.metadata = {'url': "/providers/Microsoft.Subscription/subscriptions/{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 26bb2d0ab159..5e2e456981fd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -29,32 +29,33 @@ def build_add_update_policy_for_tenant_request( *, - json: JSONType = None, + json: Optional[_models.PutTenantPolicyRequestProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies/default') + _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -64,24 +65,26 @@ def build_add_update_policy_for_tenant_request( def build_get_policy_for_tenant_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies/default') + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -89,83 +92,97 @@ def build_get_policy_for_tenant_request( def build_list_policy_for_tenant_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Subscription/policies') + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionPolicyOperations(object): - """SubscriptionPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`subscription_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def add_update_policy_for_tenant( self, - body: "_models.PutTenantPolicyRequestProperties", + body: _models.PutTenantPolicyRequestProperties, **kwargs: Any - ) -> "_models.GetTenantPolicyResponse": + ) -> _models.GetTenantPolicyResponse: """Create or Update Subscription tenant policy for user's tenant. :param body: :type body: ~azure.mgmt.subscription.models.PutTenantPolicyRequestProperties + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GetTenantPolicyResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyResponse] _json = self._serialize.body(body, 'PutTenantPolicyRequestProperties') request = build_add_update_policy_for_tenant_request( + api_version=api_version, content_type=content_type, json=_json, template_url=self.add_update_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,35 +197,50 @@ def add_update_policy_for_tenant( return deserialized - add_update_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + add_update_policy_for_tenant.metadata = {'url': "/providers/Microsoft.Subscription/policies/default"} # type: ignore @distributed_trace def get_policy_for_tenant( self, **kwargs: Any - ) -> "_models.GetTenantPolicyResponse": + ) -> _models.GetTenantPolicyResponse: """Get the subscription tenant policy for the user's tenant. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GetTenantPolicyResponse, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.GetTenantPolicyResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyResponse] request = build_get_policy_for_tenant_request( + api_version=api_version, template_url=self.get_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,16 +255,19 @@ def get_policy_for_tenant( return deserialized - get_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies/default'} # type: ignore + get_policy_for_tenant.metadata = {'url': "/providers/Microsoft.Subscription/policies/default"} # type: ignore @distributed_trace def list_policy_for_tenant( self, **kwargs: Any - ) -> Iterable["_models.GetTenantPolicyListResponse"]: + ) -> Iterable[_models.GetTenantPolicyListResponse]: """Get the subscription tenant policy for the user's tenant. + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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) @@ -240,27 +275,38 @@ def list_policy_for_tenant( ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.GetTenantPolicyListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetTenantPolicyListResponse"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GetTenantPolicyListResponse] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_policy_for_tenant_request( + api_version=api_version, template_url=self.list_policy_for_tenant.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_policy_for_tenant_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -274,7 +320,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,4 +338,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_policy_for_tenant.metadata = {'url': '/providers/Microsoft.Subscription/policies'} # type: ignore + list_policy_for_tenant.metadata = {'url': "/providers/Microsoft.Subscription/policies"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py index d98d56226406..507649d57333 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_locations_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/locations") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -61,29 +64,31 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -91,55 +96,55 @@ def build_get_request( def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2016-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions') + _url = kwargs.pop("template_url", "/subscriptions") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionsOperations(object): - """SubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_locations( self, subscription_id: str, **kwargs: Any - ) -> Iterable["_models.LocationListResult"]: + ) -> Iterable[_models.LocationListResult]: """Gets all available geo-locations. This operation provides all the locations that are available for resource providers; however, @@ -147,34 +152,48 @@ def list_locations( :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_locations_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.list_locations.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_locations_request( subscription_id=subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -188,7 +207,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,38 +224,53 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + list_locations.metadata = {'url': "/subscriptions/{subscriptionId}/locations"} # type: ignore @distributed_trace def get( self, subscription_id: str, **kwargs: Any - ) -> "_models.Subscription": + ) -> _models.Subscription: """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Subscription, or the result of cls(response) :rtype: ~azure.mgmt.subscription.models.Subscription :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Subscription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Subscription] request = build_get_request( subscription_id=subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,43 +284,57 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.SubscriptionListResult"]: + ) -> Iterable[_models.SubscriptionListResult]: """Gets all subscriptions for a tenant. + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +348,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -309,4 +365,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions"} # type: ignore diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py index 99febb127687..7aaf60f3d29e 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_tenants_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,82 +30,96 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2016-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/tenants') + _url = kwargs.pop("template_url", "/tenants") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantsOperations(object): - """TenantsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.subscription.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.subscription.SubscriptionClient`'s + :attr:`tenants` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.TenantListResult"]: + ) -> Iterable[_models.TenantListResult]: """Gets the tenants for your account. + :keyword api_version: Api Version. Default value is "2016-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.subscription.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +133,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -131,4 +150,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/tenants'} # type: ignore + list.metadata = {'url': "/tenants"} # type: ignore