From 9d75a20fdeceb43d63f680d4640d0ee1602e6ba8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 21 Jan 2022 20:27:17 +0000 Subject: [PATCH] CodeGen from PR 17454 in Azure/azure-rest-api-specs Merge 683c8fee34817da212fef3f7f37bfa7880fbfb8f into a4def981588f1c39ee8d795fdcf6e8594e9a01dc --- sdk/quota/azure-mgmt-quota/_meta.json | 10 +- .../azure/mgmt/quota/__init__.py | 9 +- .../mgmt/quota/_azure_quota_extension_api.py | 87 +- .../azure/mgmt/quota/_configuration.py | 17 +- .../azure/mgmt/quota/_metadata.json | 21 +- .../azure/mgmt/quota/_patch.py | 31 + .../azure/mgmt/quota/_vendor.py | 27 + .../azure/mgmt/quota/_version.py | 2 +- .../azure/mgmt/quota/aio/__init__.py | 5 + .../quota/aio/_azure_quota_extension_api.py | 75 +- .../azure/mgmt/quota/aio/_configuration.py | 6 +- .../azure/mgmt/quota/aio/_patch.py | 31 + .../operations/_quota_operation_operations.py | 44 +- .../quota/aio/operations/_quota_operations.py | 220 ++-- .../_quota_request_status_operations.py | 101 +- .../aio/operations/_usages_operations.py | 84 +- .../azure/mgmt/quota/models/__init__.py | 81 +- .../_azure_quota_extension_api_enums.py | 27 +- .../azure/mgmt/quota/models/_models.py | 1018 ----------------- .../azure/mgmt/quota/models/_models_py3.py | 406 +++++-- .../operations/_quota_operation_operations.py | 85 +- .../quota/operations/_quota_operations.py | 440 ++++--- .../_quota_request_status_operations.py | 205 ++-- .../quota/operations/_usages_operations.py | 175 ++- 24 files changed, 1330 insertions(+), 1877 deletions(-) create mode 100644 sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_patch.py create mode 100644 sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py create mode 100644 sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_patch.py delete mode 100644 sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models.py diff --git a/sdk/quota/azure-mgmt-quota/_meta.json b/sdk/quota/azure-mgmt-quota/_meta.json index c011ed505d51..b8711cbc3eab 100644 --- a/sdk/quota/azure-mgmt-quota/_meta.json +++ b/sdk/quota/azure-mgmt-quota/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "348665d474283df6a73d6a2ec6defef271251f13", + "commit": "3b26ad8272fdcfbd6c310c9821dcba1f20f4dea0", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/quota/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/quota/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/quota/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py index e3a34f9e8ab9..a07301047941 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AzureQuotaExtensionAPI'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_azure_quota_extension_api.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_azure_quota_extension_api.py index 625493b8b8f7..9f2be5138ec8 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_azure_quota_extension_api.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_azure_quota_extension_api.py @@ -6,27 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AzureQuotaExtensionAPIConfiguration +from .operations import QuotaOperationOperations, QuotaOperations, QuotaRequestStatusOperations, UsagesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AzureQuotaExtensionAPIConfiguration -from .operations import UsagesOperations -from .operations import QuotaOperations -from .operations import QuotaRequestStatusOperations -from .operations import QuotaOperationOperations -from . import models - -class AzureQuotaExtensionAPI(object): +class AzureQuotaExtensionAPI: """Microsoft Azure Quota Resource Provider. :ivar usages: UsagesOperations operations @@ -39,50 +34,56 @@ class AzureQuotaExtensionAPI(object): :vartype quota_operation: azure.mgmt.quota.operations.QuotaOperationOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureQuotaExtensionAPIConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureQuotaExtensionAPIConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota = QuotaOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_request_status = QuotaRequestStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_operation = QuotaOperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota = QuotaOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota_request_status = QuotaRequestStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota_operation = QuotaOperationOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py index 04bee75ccc66..eff63828eb48 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class AzureQuotaExtensionAPIConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(AzureQuotaExtensionAPIConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AzureQuotaExtensionAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-03-15-preview" @@ -62,4 +59,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_metadata.json b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_metadata.json index 9319b687bfc5..bda05fcd22f5 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_metadata.json +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_metadata.json @@ -5,13 +5,13 @@ "name": "AzureQuotaExtensionAPI", "filename": "_azure_quota_extension_api", "description": "Microsoft Azure Quota Resource Provider.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureQuotaExtensionAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureQuotaExtensionAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureQuotaExtensionAPIConfiguration\"]}}, \"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\": [\"AzureQuotaExtensionAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "usages": "UsagesOperations", diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_patch.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_version.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_version.py index dfa6ee022f15..e5754a47ce68 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_version.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py index ab00c327b957..28000e9a3b91 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py @@ -8,3 +8,8 @@ from ._azure_quota_extension_api import AzureQuotaExtensionAPI __all__ = ['AzureQuotaExtensionAPI'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_azure_quota_extension_api.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_azure_quota_extension_api.py index b71939d8524c..c1f982f0750b 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_azure_quota_extension_api.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_azure_quota_extension_api.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import AzureQuotaExtensionAPIConfiguration +from .operations import QuotaOperationOperations, QuotaOperations, QuotaRequestStatusOperations, UsagesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AzureQuotaExtensionAPIConfiguration -from .operations import UsagesOperations -from .operations import QuotaOperations -from .operations import QuotaRequestStatusOperations -from .operations import QuotaOperationOperations -from .. import models - - -class AzureQuotaExtensionAPI(object): +class AzureQuotaExtensionAPI: """Microsoft Azure Quota Resource Provider. :ivar usages: UsagesOperations operations @@ -37,48 +34,56 @@ class AzureQuotaExtensionAPI(object): :vartype quota_operation: azure.mgmt.quota.aio.operations.QuotaOperationOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureQuotaExtensionAPIConfiguration(credential, **kwargs) + self._config = AzureQuotaExtensionAPIConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota = QuotaOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_request_status = QuotaRequestStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.quota_operation = QuotaOperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota = QuotaOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota_request_status = QuotaRequestStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quota_operation = QuotaOperationOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py index f099610bf3e8..a227a034c5f6 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(AzureQuotaExtensionAPIConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AzureQuotaExtensionAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-03-15-preview" @@ -58,4 +58,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_patch.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operation_operations.py index 1b874a4117f7..3dc6d32daa6f 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operation_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operation_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._quota_operation_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -59,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +98,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operations.py index 6d727925e11a..4a9b5ff84bed 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_operations.py @@ -5,19 +5,24 @@ # 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, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._quota_operations import build_create_or_update_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_name: str, @@ -75,44 +81,37 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_name=resource_name, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_name: str, @@ -125,38 +124,27 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_name=resource_name, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -166,8 +154,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_name: str, @@ -203,15 +194,19 @@ async def begin_create_or_update( :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CurrentQuotaLimitBase or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CurrentQuotaLimitBase or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] lro_delay = kwargs.pop( 'polling_interval', @@ -223,26 +218,21 @@ async def begin_create_or_update( resource_name=resource_name, scope=scope, create_quota_request=create_quota_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -254,6 +244,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore async def _update_initial( @@ -268,38 +259,27 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + + request = build_update_request_initial( + resource_name=resource_name, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -309,8 +289,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_name: str, @@ -345,15 +328,19 @@ async def begin_update( :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either CurrentQuotaLimitBase or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CurrentQuotaLimitBase or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] lro_delay = kwargs.pop( 'polling_interval', @@ -365,26 +352,21 @@ async def begin_update( resource_name=resource_name, scope=scope, create_quota_request=create_quota_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -396,8 +378,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + @distributed_trace def list( self, scope: str, @@ -422,34 +406,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('QuotaLimits', pipeline_response) + deserialized = self._deserialize("QuotaLimits", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -462,12 +441,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_request_status_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_request_status_operations.py index ca672462d4e0..957585992503 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_request_status_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_quota_request_status_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._quota_request_status_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, id: str, @@ -69,32 +75,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + id=id, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaRequestDetails', pipeline_response) @@ -103,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotaRequests/{id}'} # type: ignore + + @distributed_trace def list( self, scope: str, @@ -141,8 +140,10 @@ def list( **skiptoken** parameter that specifies a starting point to use for subsequent calls. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either QuotaRequestDetailsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.QuotaRequestDetailsList] + :return: An iterator like instance of either QuotaRequestDetailsList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.QuotaRequestDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaRequestDetailsList"] @@ -150,40 +151,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('QuotaRequestDetailsList', pipeline_response) + deserialized = self._deserialize("QuotaRequestDetailsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -196,12 +192,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_usages_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_usages_operations.py index bfcdb7333b47..83835c98e913 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_usages_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_usages_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usages_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_name: str, @@ -72,44 +78,38 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_name=resource_name, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentUsagesBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/usages/{resourceName}'} # type: ignore + + @distributed_trace def list( self, scope: str, @@ -133,34 +133,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesLimits', pipeline_response) + deserialized = self._deserialize("UsagesLimits", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -173,12 +168,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py index 4e46eef56772..7d3bb6f4adca 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py @@ -6,60 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CommonResourceProperties - from ._models_py3 import CreateGenericQuotaRequestParameters - from ._models_py3 import CurrentQuotaLimitBase - from ._models_py3 import CurrentUsagesBase - from ._models_py3 import ExceptionResponse - from ._models_py3 import LimitJsonObject - from ._models_py3 import LimitObject - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import OperationResponse - from ._models_py3 import QuotaLimits - from ._models_py3 import QuotaLimitsResponse - from ._models_py3 import QuotaProperties - from ._models_py3 import QuotaRequestDetails - from ._models_py3 import QuotaRequestDetailsList - from ._models_py3 import QuotaRequestOneResourceSubmitResponse - from ._models_py3 import QuotaRequestProperties - from ._models_py3 import QuotaRequestSubmitResponse - from ._models_py3 import QuotaRequestSubmitResponse202 - from ._models_py3 import ResourceName - from ._models_py3 import ServiceError - from ._models_py3 import ServiceErrorDetail - from ._models_py3 import SubRequest - from ._models_py3 import UsagesLimits - from ._models_py3 import UsagesObject - from ._models_py3 import UsagesProperties -except (SyntaxError, ImportError): - from ._models import CommonResourceProperties # type: ignore - from ._models import CreateGenericQuotaRequestParameters # type: ignore - from ._models import CurrentQuotaLimitBase # type: ignore - from ._models import CurrentUsagesBase # type: ignore - from ._models import ExceptionResponse # type: ignore - from ._models import LimitJsonObject # type: ignore - from ._models import LimitObject # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import OperationResponse # type: ignore - from ._models import QuotaLimits # type: ignore - from ._models import QuotaLimitsResponse # type: ignore - from ._models import QuotaProperties # type: ignore - from ._models import QuotaRequestDetails # type: ignore - from ._models import QuotaRequestDetailsList # type: ignore - from ._models import QuotaRequestOneResourceSubmitResponse # type: ignore - from ._models import QuotaRequestProperties # type: ignore - from ._models import QuotaRequestSubmitResponse # type: ignore - from ._models import QuotaRequestSubmitResponse202 # type: ignore - from ._models import ResourceName # type: ignore - from ._models import ServiceError # type: ignore - from ._models import ServiceErrorDetail # type: ignore - from ._models import SubRequest # type: ignore - from ._models import UsagesLimits # type: ignore - from ._models import UsagesObject # type: ignore - from ._models import UsagesProperties # type: ignore +from ._models_py3 import CommonResourceProperties +from ._models_py3 import CreateGenericQuotaRequestParameters +from ._models_py3 import CurrentQuotaLimitBase +from ._models_py3 import CurrentUsagesBase +from ._models_py3 import ExceptionResponse +from ._models_py3 import LimitJsonObject +from ._models_py3 import LimitObject +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import OperationResponse +from ._models_py3 import QuotaLimits +from ._models_py3 import QuotaLimitsResponse +from ._models_py3 import QuotaProperties +from ._models_py3 import QuotaRequestDetails +from ._models_py3 import QuotaRequestDetailsList +from ._models_py3 import QuotaRequestOneResourceSubmitResponse +from ._models_py3 import QuotaRequestProperties +from ._models_py3 import QuotaRequestSubmitResponse +from ._models_py3 import QuotaRequestSubmitResponse202 +from ._models_py3 import ResourceName +from ._models_py3 import ServiceError +from ._models_py3 import ServiceErrorDetail +from ._models_py3 import SubRequest +from ._models_py3 import UsagesLimits +from ._models_py3 import UsagesObject +from ._models_py3 import UsagesProperties + from ._azure_quota_extension_api_enums import ( LimitType, diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_azure_quota_extension_api_enums.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_azure_quota_extension_api_enums.py index acb53f1316eb..438a573df8bc 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_azure_quota_extension_api_enums.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_azure_quota_extension_api_enums.py @@ -6,40 +6,25 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class LimitType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LimitType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The limit object type. """ LIMIT_VALUE = "LimitValue" -class QuotaLimitTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QuotaLimitTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The quota or usages limit types. """ INDEPENDENT = "Independent" SHARED = "Shared" -class QuotaRequestState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QuotaRequestState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Quota request status. """ @@ -49,7 +34,7 @@ class QuotaRequestState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" IN_PROGRESS = "InProgress" -class UsagesTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsagesTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The quota or usages limit types. """ diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models.py deleted file mode 100644 index e39626514d18..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models.py +++ /dev/null @@ -1,1018 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class CommonResourceProperties(msrest.serialization.Model): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. Example: "Microsoft.Quota/quotas". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommonResourceProperties, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class CreateGenericQuotaRequestParameters(msrest.serialization.Model): - """Quota change requests information. - - :param value: Quota change requests. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateGenericQuotaRequestParameters, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CurrentQuotaLimitBase(msrest.serialization.Model): - """Quota limit. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource ID. - :vartype id: str - :ivar type: The resource type. - :vartype type: str - :ivar name: The resource name. - :vartype name: str - :param properties: Quota properties for the specified resource, based on the API called, Quotas - or Usages. - :type properties: ~azure.mgmt.quota.models.QuotaProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'QuotaProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CurrentQuotaLimitBase, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.properties = kwargs.get('properties', None) - - -class CurrentUsagesBase(msrest.serialization.Model): - """Resource usage. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource ID. - :vartype id: str - :ivar type: The resource type. - :vartype type: str - :ivar name: The resource name. - :vartype name: str - :param properties: Usage properties for the specified resource. - :type properties: ~azure.mgmt.quota.models.UsagesProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'UsagesProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CurrentUsagesBase, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.properties = kwargs.get('properties', None) - - -class ExceptionResponse(msrest.serialization.Model): - """Error. - - :param error: API error details. - :type error: ~azure.mgmt.quota.models.ServiceError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ServiceError'}, - } - - def __init__( - self, - **kwargs - ): - super(ExceptionResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class LimitJsonObject(msrest.serialization.Model): - """LimitJson abstract class. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LimitObject. - - All required parameters must be populated in order to send to Azure. - - :param limit_object_type: Required. The limit object type.Constant filled by server. Possible - values include: "LimitValue". - :type limit_object_type: str or ~azure.mgmt.quota.models.LimitType - """ - - _validation = { - 'limit_object_type': {'required': True}, - } - - _attribute_map = { - 'limit_object_type': {'key': 'limitObjectType', 'type': 'str'}, - } - - _subtype_map = { - 'limit_object_type': {'LimitValue': 'LimitObject'} - } - - def __init__( - self, - **kwargs - ): - super(LimitJsonObject, self).__init__(**kwargs) - self.limit_object_type = None # type: Optional[str] - - -class LimitObject(LimitJsonObject): - """The resource quota limit value. - - All required parameters must be populated in order to send to Azure. - - :param limit_object_type: Required. The limit object type.Constant filled by server. Possible - values include: "LimitValue". - :type limit_object_type: str or ~azure.mgmt.quota.models.LimitType - :param value: Required. The quota/limit value. - :type value: int - :param limit_type: The quota or usages limit types. Possible values include: "Independent", - "Shared". - :type limit_type: str or ~azure.mgmt.quota.models.QuotaLimitTypes - """ - - _validation = { - 'limit_object_type': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'limit_object_type': {'key': 'limitObjectType', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'int'}, - 'limit_type': {'key': 'limitType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LimitObject, self).__init__(**kwargs) - self.limit_object_type = 'LimitValue' # type: str - self.value = kwargs['value'] - self.limit_type = kwargs.get('limit_type', None) - - -class OperationDisplay(msrest.serialization.Model): - """OperationDisplay. - - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Operation description. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """OperationList. - - :param value: - :type value: list[~azure.mgmt.quota.models.OperationResponse] - :param next_link: URL to get the next page of items. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class OperationResponse(msrest.serialization.Model): - """OperationResponse. - - :param name: - :type name: str - :param display: - :type display: ~azure.mgmt.quota.models.OperationDisplay - :param origin: - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResponse, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class QuotaLimits(msrest.serialization.Model): - """Quota limits. - - :param value: List of quota limits. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more - pages, this string is null. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaLimits, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class QuotaLimitsResponse(msrest.serialization.Model): - """Quota limits request response. - - :param value: List of quota limits with the quota request status. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more - pages, this is null. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaLimitsResponse, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class QuotaProperties(msrest.serialization.Model): - """Quota properties for the specified resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitJsonObject - :ivar unit: The quota units, such as Count and Bytes. When requesting quota, use the **unit** - value returned in the GET response in the request body of your PUT operation. - :vartype unit: str - :param name: Resource name provided by the resource provider. Use this property name when - requesting quota. - :type name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str - :ivar quota_period: The time period over which the quota usage values are summarized. For - example: - *P1D (per one day)*\ PT1M (per one minute) - *PT1S (per one second). - This parameter is optional because, for some resources like compute, the period is irrelevant. - :vartype quota_period: str - :ivar is_quota_applicable: States if quota can be requested for this resource. - :vartype is_quota_applicable: bool - :param properties: Additional properties for the specific resource provider. - :type properties: any - """ - - _validation = { - 'unit': {'readonly': True}, - 'quota_period': {'readonly': True}, - 'is_quota_applicable': {'readonly': True}, - } - - _attribute_map = { - 'limit': {'key': 'limit', 'type': 'LimitJsonObject'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'ResourceName'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, - 'is_quota_applicable': {'key': 'isQuotaApplicable', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaProperties, self).__init__(**kwargs) - self.limit = kwargs.get('limit', None) - self.unit = None - self.name = kwargs.get('name', None) - self.resource_type = kwargs.get('resource_type', None) - self.quota_period = None - self.is_quota_applicable = None - self.properties = kwargs.get('properties', None) - - -class QuotaRequestDetails(msrest.serialization.Model): - """List of quota requests with details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Quota request ID. - :vartype id: str - :ivar name: Quota request name. - :vartype name: str - :ivar type: Resource type. "Microsoft.Quota/quotas". - :vartype type: str - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState - :ivar message: User-friendly status message. - :vartype message: str - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail - :ivar request_submit_time: The quota request submission time. The date conforms to the - following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. - :vartype request_submit_time: ~datetime.datetime - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.SubRequest] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'message': {'readonly': True}, - 'request_submit_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'message': {'key': 'properties.message', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ServiceErrorDetail'}, - 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, - 'value': {'key': 'properties.value', 'type': '[SubRequest]'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestDetails, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.provisioning_state = None - self.message = None - self.error = kwargs.get('error', None) - self.request_submit_time = None - self.value = kwargs.get('value', None) - - -class QuotaRequestDetailsList(msrest.serialization.Model): - """Quota request information. - - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.QuotaRequestDetails] - :param next_link: The URI for fetching the next page of quota limits. When there are no more - pages, this string is null. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[QuotaRequestDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestDetailsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): - """Quota request response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Quota request ID. - :vartype id: str - :ivar name: The name of the quota request. - :vartype name: str - :ivar type: Resource type. "Microsoft.Quota/ServiceLimitRequests". - :vartype type: str - :ivar provisioning_state: Quota request status. Possible values include: "Accepted", "Invalid", - "Succeeded", "Failed", "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState - :ivar message: User-friendly status message. - :vartype message: str - :ivar request_submit_time: Quota request submission time. The date conforms to the following - ISO 8601 standard format: yyyy-MM-ddTHH:mm:ssZ. - :vartype request_submit_time: ~datetime.datetime - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitObject - :ivar current_value: Usage information for the current resource. - :vartype current_value: int - :param unit: The quota limit units, such as Count and Bytes. When requesting quota, use the - **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str - :param name_properties_name: Resource name provided by the resource provider. Use this property - name when requesting quota. - :type name_properties_name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str - :ivar quota_period: The time period over which the quota usage values are summarized. For - example: - *P1D (per one day)*\ PT1M (per one minute) - *PT1S (per one second). - This parameter is optional because, for some resources like compute, the period is irrelevant. - :vartype quota_period: str - :ivar is_quota_applicable: States if quota can be requested for this resource. - :vartype is_quota_applicable: bool - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail - :param properties: Additional properties for the specific resource provider. - :type properties: any - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'message': {'readonly': True}, - 'request_submit_time': {'readonly': True}, - 'current_value': {'readonly': True}, - 'quota_period': {'readonly': True}, - 'is_quota_applicable': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'message': {'key': 'properties.message', 'type': 'str'}, - 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, - 'limit': {'key': 'properties.limit', 'type': 'LimitObject'}, - 'current_value': {'key': 'properties.currentValue', 'type': 'int'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'ResourceName'}, - 'resource_type': {'key': 'properties.resourceType', 'type': 'str'}, - 'quota_period': {'key': 'properties.quotaPeriod', 'type': 'str'}, - 'is_quota_applicable': {'key': 'properties.isQuotaApplicable', 'type': 'bool'}, - 'error': {'key': 'properties.error', 'type': 'ServiceErrorDetail'}, - 'properties': {'key': 'properties.properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestOneResourceSubmitResponse, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.provisioning_state = None - self.message = None - self.request_submit_time = None - self.limit = kwargs.get('limit', None) - self.current_value = None - self.unit = kwargs.get('unit', None) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.resource_type = kwargs.get('resource_type', None) - self.quota_period = None - self.is_quota_applicable = None - self.error = kwargs.get('error', None) - self.properties = kwargs.get('properties', None) - - -class QuotaRequestProperties(msrest.serialization.Model): - """Quota request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState - :ivar message: User-friendly status message. - :vartype message: str - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail - :ivar request_submit_time: The quota request submission time. The date conforms to the - following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. - :vartype request_submit_time: ~datetime.datetime - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.SubRequest] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'message': {'readonly': True}, - 'request_submit_time': {'readonly': True}, - } - - _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ServiceErrorDetail'}, - 'request_submit_time': {'key': 'requestSubmitTime', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': '[SubRequest]'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.message = None - self.error = kwargs.get('error', None) - self.request_submit_time = None - self.value = kwargs.get('value', None) - - -class QuotaRequestSubmitResponse(msrest.serialization.Model): - """Quota request response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Quota request ID. - :vartype id: str - :ivar name: Quota request name. - :vartype name: str - :param properties: Quota request details. - :type properties: ~azure.mgmt.quota.models.QuotaRequestProperties - :ivar type: Resource type. "Microsoft.Quota/quotas". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'QuotaRequestProperties'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestSubmitResponse, self).__init__(**kwargs) - self.id = None - self.name = None - self.properties = kwargs.get('properties', None) - self.type = None - - -class QuotaRequestSubmitResponse202(msrest.serialization.Model): - """The quota request response with the quota request ID. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The quota request ID. To check the request status, use the **id** value in a `Quota - Request Status - `_ GET - operation. - :vartype id: str - :ivar name: Operation ID. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Quota request status. Possible values include: "Accepted", "Invalid", - "Succeeded", "Failed", "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState - :ivar message: User-friendly message. - :vartype message: str - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitObject - :param unit: The quota limit units, such as Count and Bytes. When requesting quota, use the - **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str - :param name_properties_name: Resource name provided by the resource provider. Use this property - name when requesting quota. - :type name_properties_name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str - :ivar quota_period: The time period over which the quota usage values are summarized. For - example: - *P1D (per one day)*\ PT1M (per one minute) - *PT1S (per one second). - This parameter is optional because, for some resources like compute, the period is irrelevant. - :vartype quota_period: str - :param properties: Additional properties for the specific resource provider. - :type properties: any - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'message': {'readonly': True}, - 'quota_period': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'message': {'key': 'properties.message', 'type': 'str'}, - 'limit': {'key': 'properties.limit', 'type': 'LimitObject'}, - 'unit': {'key': 'properties.unit', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'ResourceName'}, - 'resource_type': {'key': 'properties.resourceType', 'type': 'str'}, - 'quota_period': {'key': 'properties.quotaPeriod', 'type': 'str'}, - 'properties': {'key': 'properties.properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaRequestSubmitResponse202, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.provisioning_state = None - self.message = None - self.limit = kwargs.get('limit', None) - self.unit = kwargs.get('unit', None) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.resource_type = kwargs.get('resource_type', None) - self.quota_period = None - self.properties = kwargs.get('properties', None) - - -class ResourceName(msrest.serialization.Model): - """Name of the resource provided by the resource Provider. When requesting quota, use this property name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Resource name. - :type value: str - :ivar localized_value: Resource display name. - :vartype localized_value: str - """ - - _validation = { - 'localized_value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceName, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = None - - -class ServiceError(msrest.serialization.Model): - """API error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param code: Error code. - :type code: str - :param message: Error message. - :type message: str - :ivar details: List of error details. - :vartype details: list[~azure.mgmt.quota.models.ServiceErrorDetail] - """ - - _validation = { - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ServiceErrorDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = None - - -class ServiceErrorDetail(msrest.serialization.Model): - """Error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - - -class SubRequest(msrest.serialization.Model): - """Request property. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Resource name. - :type name: ~azure.mgmt.quota.models.ResourceName - :ivar resource_type: Resource type for which the quota properties were requested. - :vartype resource_type: str - :param unit: Quota limit units, such as Count and Bytes. When requesting quota, use the - **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". - :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState - :ivar message: User-friendly status message. - :vartype message: str - :ivar sub_request_id: Quota request ID. - :vartype sub_request_id: str - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitJsonObject - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'message': {'readonly': True}, - 'sub_request_id': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'ResourceName'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'sub_request_id': {'key': 'subRequestId', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'LimitJsonObject'}, - } - - def __init__( - self, - **kwargs - ): - super(SubRequest, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.resource_type = None - self.unit = kwargs.get('unit', None) - self.provisioning_state = None - self.message = None - self.sub_request_id = None - self.limit = kwargs.get('limit', None) - - -class UsagesLimits(msrest.serialization.Model): - """Quota limits. - - :param value: List of quota limits. - :type value: list[~azure.mgmt.quota.models.CurrentUsagesBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more - pages, this is null. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CurrentUsagesBase]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsagesLimits, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class UsagesObject(msrest.serialization.Model): - """The resource usages value. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The usages value. - :type value: int - :param usages_type: The quota or usages limit types. Possible values include: "Individual", - "Combined". - :type usages_type: str or ~azure.mgmt.quota.models.UsagesTypes - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'int'}, - 'usages_type': {'key': 'usagesType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsagesObject, self).__init__(**kwargs) - self.value = kwargs['value'] - self.usages_type = kwargs.get('usages_type', None) - - -class UsagesProperties(msrest.serialization.Model): - """Usage properties for the specified resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param usages: The quota limit properties for this resource. - :type usages: ~azure.mgmt.quota.models.UsagesObject - :ivar unit: The units for the quota usage, such as Count and Bytes. When requesting quota, use - the **unit** value returned in the GET response in the request body of your PUT operation. - :vartype unit: str - :param name: Resource name provided by the resource provider. Use this property name when - requesting quota. - :type name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: The name of the resource type. - :type resource_type: str - :ivar quota_period: The time period for the summary of the quota usage values. For example: - *P1D (per one day)*\ PT1M (per one minute) - *PT1S (per one second). - This parameter is optional because it is not relevant for all resources such as compute. - :vartype quota_period: str - :ivar is_quota_applicable: States if quota can be requested for this resource. - :vartype is_quota_applicable: bool - :param properties: Additional properties for the specific resource provider. - :type properties: any - """ - - _validation = { - 'unit': {'readonly': True}, - 'quota_period': {'readonly': True}, - 'is_quota_applicable': {'readonly': True}, - } - - _attribute_map = { - 'usages': {'key': 'usages', 'type': 'UsagesObject'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'ResourceName'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, - 'is_quota_applicable': {'key': 'isQuotaApplicable', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(UsagesProperties, self).__init__(**kwargs) - self.usages = kwargs.get('usages', None) - self.unit = None - self.name = kwargs.get('name', None) - self.resource_type = kwargs.get('resource_type', None) - self.quota_period = None - self.is_quota_applicable = None - self.properties = kwargs.get('properties', None) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models_py3.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models_py3.py index 88a6eb5d100a..fa37d181dca4 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models_py3.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_models_py3.py @@ -43,6 +43,8 @@ def __init__( self, **kwargs ): + """ + """ super(CommonResourceProperties, self).__init__(**kwargs) self.id = None self.name = None @@ -52,8 +54,8 @@ def __init__( class CreateGenericQuotaRequestParameters(msrest.serialization.Model): """Quota change requests information. - :param value: Quota change requests. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + :ivar value: Quota change requests. + :vartype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] """ _attribute_map = { @@ -66,6 +68,10 @@ def __init__( value: Optional[List["CurrentQuotaLimitBase"]] = None, **kwargs ): + """ + :keyword value: Quota change requests. + :paramtype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + """ super(CreateGenericQuotaRequestParameters, self).__init__(**kwargs) self.value = value @@ -81,9 +87,9 @@ class CurrentQuotaLimitBase(msrest.serialization.Model): :vartype type: str :ivar name: The resource name. :vartype name: str - :param properties: Quota properties for the specified resource, based on the API called, Quotas + :ivar properties: Quota properties for the specified resource, based on the API called, Quotas or Usages. - :type properties: ~azure.mgmt.quota.models.QuotaProperties + :vartype properties: ~azure.mgmt.quota.models.QuotaProperties """ _validation = { @@ -105,6 +111,11 @@ def __init__( properties: Optional["QuotaProperties"] = None, **kwargs ): + """ + :keyword properties: Quota properties for the specified resource, based on the API called, + Quotas or Usages. + :paramtype properties: ~azure.mgmt.quota.models.QuotaProperties + """ super(CurrentQuotaLimitBase, self).__init__(**kwargs) self.id = None self.type = None @@ -123,8 +134,8 @@ class CurrentUsagesBase(msrest.serialization.Model): :vartype type: str :ivar name: The resource name. :vartype name: str - :param properties: Usage properties for the specified resource. - :type properties: ~azure.mgmt.quota.models.UsagesProperties + :ivar properties: Usage properties for the specified resource. + :vartype properties: ~azure.mgmt.quota.models.UsagesProperties """ _validation = { @@ -146,6 +157,10 @@ def __init__( properties: Optional["UsagesProperties"] = None, **kwargs ): + """ + :keyword properties: Usage properties for the specified resource. + :paramtype properties: ~azure.mgmt.quota.models.UsagesProperties + """ super(CurrentUsagesBase, self).__init__(**kwargs) self.id = None self.type = None @@ -156,8 +171,8 @@ def __init__( class ExceptionResponse(msrest.serialization.Model): """Error. - :param error: API error details. - :type error: ~azure.mgmt.quota.models.ServiceError + :ivar error: API error details. + :vartype error: ~azure.mgmt.quota.models.ServiceError """ _attribute_map = { @@ -170,6 +185,10 @@ def __init__( error: Optional["ServiceError"] = None, **kwargs ): + """ + :keyword error: API error details. + :paramtype error: ~azure.mgmt.quota.models.ServiceError + """ super(ExceptionResponse, self).__init__(**kwargs) self.error = error @@ -182,9 +201,9 @@ class LimitJsonObject(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param limit_object_type: Required. The limit object type.Constant filled by server. Possible + :ivar limit_object_type: Required. The limit object type.Constant filled by server. Possible values include: "LimitValue". - :type limit_object_type: str or ~azure.mgmt.quota.models.LimitType + :vartype limit_object_type: str or ~azure.mgmt.quota.models.LimitType """ _validation = { @@ -203,6 +222,8 @@ def __init__( self, **kwargs ): + """ + """ super(LimitJsonObject, self).__init__(**kwargs) self.limit_object_type = None # type: Optional[str] @@ -212,14 +233,14 @@ class LimitObject(LimitJsonObject): All required parameters must be populated in order to send to Azure. - :param limit_object_type: Required. The limit object type.Constant filled by server. Possible + :ivar limit_object_type: Required. The limit object type.Constant filled by server. Possible values include: "LimitValue". - :type limit_object_type: str or ~azure.mgmt.quota.models.LimitType - :param value: Required. The quota/limit value. - :type value: int - :param limit_type: The quota or usages limit types. Possible values include: "Independent", + :vartype limit_object_type: str or ~azure.mgmt.quota.models.LimitType + :ivar value: Required. The quota/limit value. + :vartype value: int + :ivar limit_type: The quota or usages limit types. Possible values include: "Independent", "Shared". - :type limit_type: str or ~azure.mgmt.quota.models.QuotaLimitTypes + :vartype limit_type: str or ~azure.mgmt.quota.models.QuotaLimitTypes """ _validation = { @@ -240,6 +261,13 @@ def __init__( limit_type: Optional[Union[str, "QuotaLimitTypes"]] = None, **kwargs ): + """ + :keyword value: Required. The quota/limit value. + :paramtype value: int + :keyword limit_type: The quota or usages limit types. Possible values include: "Independent", + "Shared". + :paramtype limit_type: str or ~azure.mgmt.quota.models.QuotaLimitTypes + """ super(LimitObject, self).__init__(**kwargs) self.limit_object_type = 'LimitValue' # type: str self.value = value @@ -249,14 +277,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """OperationDisplay. - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Operation description. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -275,6 +303,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -285,10 +323,10 @@ def __init__( class OperationList(msrest.serialization.Model): """OperationList. - :param value: - :type value: list[~azure.mgmt.quota.models.OperationResponse] - :param next_link: URL to get the next page of items. - :type next_link: str + :ivar value: + :vartype value: list[~azure.mgmt.quota.models.OperationResponse] + :ivar next_link: URL to get the next page of items. + :vartype next_link: str """ _attribute_map = { @@ -303,6 +341,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.quota.models.OperationResponse] + :keyword next_link: URL to get the next page of items. + :paramtype next_link: str + """ super(OperationList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -311,12 +355,12 @@ def __init__( class OperationResponse(msrest.serialization.Model): """OperationResponse. - :param name: - :type name: str - :param display: - :type display: ~azure.mgmt.quota.models.OperationDisplay - :param origin: - :type origin: str + :ivar name: + :vartype name: str + :ivar display: + :vartype display: ~azure.mgmt.quota.models.OperationDisplay + :ivar origin: + :vartype origin: str """ _attribute_map = { @@ -333,6 +377,14 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: + :paramtype name: str + :keyword display: + :paramtype display: ~azure.mgmt.quota.models.OperationDisplay + :keyword origin: + :paramtype origin: str + """ super(OperationResponse, self).__init__(**kwargs) self.name = name self.display = display @@ -342,11 +394,11 @@ def __init__( class QuotaLimits(msrest.serialization.Model): """Quota limits. - :param value: List of quota limits. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more + :ivar value: List of quota limits. + :vartype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + :ivar next_link: The URI used to fetch the next page of quota limits. When there are no more pages, this string is null. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -361,6 +413,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of quota limits. + :paramtype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + :keyword next_link: The URI used to fetch the next page of quota limits. When there are no more + pages, this string is null. + :paramtype next_link: str + """ super(QuotaLimits, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -369,11 +428,11 @@ def __init__( class QuotaLimitsResponse(msrest.serialization.Model): """Quota limits request response. - :param value: List of quota limits with the quota request status. - :type value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more + :ivar value: List of quota limits with the quota request status. + :vartype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + :ivar next_link: The URI used to fetch the next page of quota limits. When there are no more pages, this is null. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -388,6 +447,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of quota limits with the quota request status. + :paramtype value: list[~azure.mgmt.quota.models.CurrentQuotaLimitBase] + :keyword next_link: The URI used to fetch the next page of quota limits. When there are no more + pages, this is null. + :paramtype next_link: str + """ super(QuotaLimitsResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -398,16 +464,16 @@ class QuotaProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitJsonObject + :ivar limit: Resource quota limit properties. + :vartype limit: ~azure.mgmt.quota.models.LimitJsonObject :ivar unit: The quota units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. :vartype unit: str - :param name: Resource name provided by the resource provider. Use this property name when + :ivar name: Resource name provided by the resource provider. Use this property name when requesting quota. - :type name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str + :vartype name: ~azure.mgmt.quota.models.ResourceName + :ivar resource_type: Resource type name. + :vartype resource_type: str :ivar quota_period: The time period over which the quota usage values are summarized. For example: *P1D (per one day)*\ PT1M (per one minute) @@ -416,8 +482,8 @@ class QuotaProperties(msrest.serialization.Model): :vartype quota_period: str :ivar is_quota_applicable: States if quota can be requested for this resource. :vartype is_quota_applicable: bool - :param properties: Additional properties for the specific resource provider. - :type properties: any + :ivar properties: Additional properties for the specific resource provider. + :vartype properties: any """ _validation = { @@ -445,6 +511,17 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword limit: Resource quota limit properties. + :paramtype limit: ~azure.mgmt.quota.models.LimitJsonObject + :keyword name: Resource name provided by the resource provider. Use this property name when + requesting quota. + :paramtype name: ~azure.mgmt.quota.models.ResourceName + :keyword resource_type: Resource type name. + :paramtype resource_type: str + :keyword properties: Additional properties for the specific resource provider. + :paramtype properties: any + """ super(QuotaProperties, self).__init__(**kwargs) self.limit = limit self.unit = None @@ -471,13 +548,13 @@ class QuotaRequestDetails(msrest.serialization.Model): :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState :ivar message: User-friendly status message. :vartype message: str - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail + :ivar error: Error details of the quota request. + :vartype error: ~azure.mgmt.quota.models.ServiceErrorDetail :ivar request_submit_time: The quota request submission time. The date conforms to the following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. :vartype request_submit_time: ~datetime.datetime - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.SubRequest] + :ivar value: Quota request details. + :vartype value: list[~azure.mgmt.quota.models.SubRequest] """ _validation = { @@ -507,6 +584,12 @@ def __init__( value: Optional[List["SubRequest"]] = None, **kwargs ): + """ + :keyword error: Error details of the quota request. + :paramtype error: ~azure.mgmt.quota.models.ServiceErrorDetail + :keyword value: Quota request details. + :paramtype value: list[~azure.mgmt.quota.models.SubRequest] + """ super(QuotaRequestDetails, self).__init__(**kwargs) self.id = None self.name = None @@ -521,11 +604,11 @@ def __init__( class QuotaRequestDetailsList(msrest.serialization.Model): """Quota request information. - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.QuotaRequestDetails] - :param next_link: The URI for fetching the next page of quota limits. When there are no more + :ivar value: Quota request details. + :vartype value: list[~azure.mgmt.quota.models.QuotaRequestDetails] + :ivar next_link: The URI for fetching the next page of quota limits. When there are no more pages, this string is null. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -540,6 +623,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Quota request details. + :paramtype value: list[~azure.mgmt.quota.models.QuotaRequestDetails] + :keyword next_link: The URI for fetching the next page of quota limits. When there are no more + pages, this string is null. + :paramtype next_link: str + """ super(QuotaRequestDetailsList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -564,18 +654,18 @@ class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): :ivar request_submit_time: Quota request submission time. The date conforms to the following ISO 8601 standard format: yyyy-MM-ddTHH:mm:ssZ. :vartype request_submit_time: ~datetime.datetime - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitObject + :ivar limit: Resource quota limit properties. + :vartype limit: ~azure.mgmt.quota.models.LimitObject :ivar current_value: Usage information for the current resource. :vartype current_value: int - :param unit: The quota limit units, such as Count and Bytes. When requesting quota, use the + :ivar unit: The quota limit units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str - :param name_properties_name: Resource name provided by the resource provider. Use this property + :vartype unit: str + :ivar name_properties_name: Resource name provided by the resource provider. Use this property name when requesting quota. - :type name_properties_name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str + :vartype name_properties_name: ~azure.mgmt.quota.models.ResourceName + :ivar resource_type: Resource type name. + :vartype resource_type: str :ivar quota_period: The time period over which the quota usage values are summarized. For example: *P1D (per one day)*\ PT1M (per one minute) @@ -584,10 +674,10 @@ class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): :vartype quota_period: str :ivar is_quota_applicable: States if quota can be requested for this resource. :vartype is_quota_applicable: bool - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail - :param properties: Additional properties for the specific resource provider. - :type properties: any + :ivar error: Error details of the quota request. + :vartype error: ~azure.mgmt.quota.models.ServiceErrorDetail + :ivar properties: Additional properties for the specific resource provider. + :vartype properties: any """ _validation = { @@ -631,6 +721,22 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword limit: Resource quota limit properties. + :paramtype limit: ~azure.mgmt.quota.models.LimitObject + :keyword unit: The quota limit units, such as Count and Bytes. When requesting quota, use the + **unit** value returned in the GET response in the request body of your PUT operation. + :paramtype unit: str + :keyword name_properties_name: Resource name provided by the resource provider. Use this + property name when requesting quota. + :paramtype name_properties_name: ~azure.mgmt.quota.models.ResourceName + :keyword resource_type: Resource type name. + :paramtype resource_type: str + :keyword error: Error details of the quota request. + :paramtype error: ~azure.mgmt.quota.models.ServiceErrorDetail + :keyword properties: Additional properties for the specific resource provider. + :paramtype properties: any + """ super(QuotaRequestOneResourceSubmitResponse, self).__init__(**kwargs) self.id = None self.name = None @@ -659,13 +765,13 @@ class QuotaRequestProperties(msrest.serialization.Model): :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState :ivar message: User-friendly status message. :vartype message: str - :param error: Error details of the quota request. - :type error: ~azure.mgmt.quota.models.ServiceErrorDetail + :ivar error: Error details of the quota request. + :vartype error: ~azure.mgmt.quota.models.ServiceErrorDetail :ivar request_submit_time: The quota request submission time. The date conforms to the following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ. :vartype request_submit_time: ~datetime.datetime - :param value: Quota request details. - :type value: list[~azure.mgmt.quota.models.SubRequest] + :ivar value: Quota request details. + :vartype value: list[~azure.mgmt.quota.models.SubRequest] """ _validation = { @@ -689,6 +795,12 @@ def __init__( value: Optional[List["SubRequest"]] = None, **kwargs ): + """ + :keyword error: Error details of the quota request. + :paramtype error: ~azure.mgmt.quota.models.ServiceErrorDetail + :keyword value: Quota request details. + :paramtype value: list[~azure.mgmt.quota.models.SubRequest] + """ super(QuotaRequestProperties, self).__init__(**kwargs) self.provisioning_state = None self.message = None @@ -706,8 +818,8 @@ class QuotaRequestSubmitResponse(msrest.serialization.Model): :vartype id: str :ivar name: Quota request name. :vartype name: str - :param properties: Quota request details. - :type properties: ~azure.mgmt.quota.models.QuotaRequestProperties + :ivar properties: Quota request details. + :vartype properties: ~azure.mgmt.quota.models.QuotaRequestProperties :ivar type: Resource type. "Microsoft.Quota/quotas". :vartype type: str """ @@ -731,6 +843,10 @@ def __init__( properties: Optional["QuotaRequestProperties"] = None, **kwargs ): + """ + :keyword properties: Quota request details. + :paramtype properties: ~azure.mgmt.quota.models.QuotaRequestProperties + """ super(QuotaRequestSubmitResponse, self).__init__(**kwargs) self.id = None self.name = None @@ -757,24 +873,24 @@ class QuotaRequestSubmitResponse202(msrest.serialization.Model): :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState :ivar message: User-friendly message. :vartype message: str - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitObject - :param unit: The quota limit units, such as Count and Bytes. When requesting quota, use the + :ivar limit: Resource quota limit properties. + :vartype limit: ~azure.mgmt.quota.models.LimitObject + :ivar unit: The quota limit units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str - :param name_properties_name: Resource name provided by the resource provider. Use this property + :vartype unit: str + :ivar name_properties_name: Resource name provided by the resource provider. Use this property name when requesting quota. - :type name_properties_name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: Resource type name. - :type resource_type: str + :vartype name_properties_name: ~azure.mgmt.quota.models.ResourceName + :ivar resource_type: Resource type name. + :vartype resource_type: str :ivar quota_period: The time period over which the quota usage values are summarized. For example: *P1D (per one day)*\ PT1M (per one minute) *PT1S (per one second). This parameter is optional because, for some resources like compute, the period is irrelevant. :vartype quota_period: str - :param properties: Additional properties for the specific resource provider. - :type properties: any + :ivar properties: Additional properties for the specific resource provider. + :vartype properties: any """ _validation = { @@ -810,6 +926,20 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword limit: Resource quota limit properties. + :paramtype limit: ~azure.mgmt.quota.models.LimitObject + :keyword unit: The quota limit units, such as Count and Bytes. When requesting quota, use the + **unit** value returned in the GET response in the request body of your PUT operation. + :paramtype unit: str + :keyword name_properties_name: Resource name provided by the resource provider. Use this + property name when requesting quota. + :paramtype name_properties_name: ~azure.mgmt.quota.models.ResourceName + :keyword resource_type: Resource type name. + :paramtype resource_type: str + :keyword properties: Additional properties for the specific resource provider. + :paramtype properties: any + """ super(QuotaRequestSubmitResponse202, self).__init__(**kwargs) self.id = None self.name = None @@ -829,8 +959,8 @@ class ResourceName(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Resource name. - :type value: str + :ivar value: Resource name. + :vartype value: str :ivar localized_value: Resource display name. :vartype localized_value: str """ @@ -850,6 +980,10 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Resource name. + :paramtype value: str + """ super(ResourceName, self).__init__(**kwargs) self.value = value self.localized_value = None @@ -860,10 +994,10 @@ class ServiceError(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param code: Error code. - :type code: str - :param message: Error message. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message. + :vartype message: str :ivar details: List of error details. :vartype details: list[~azure.mgmt.quota.models.ServiceErrorDetail] """ @@ -885,6 +1019,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + """ super(ServiceError, self).__init__(**kwargs) self.code = code self.message = message @@ -916,6 +1056,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServiceErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -926,13 +1068,13 @@ class SubRequest(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: Resource name. - :type name: ~azure.mgmt.quota.models.ResourceName + :ivar name: Resource name. + :vartype name: ~azure.mgmt.quota.models.ResourceName :ivar resource_type: Resource type for which the quota properties were requested. :vartype resource_type: str - :param unit: Quota limit units, such as Count and Bytes. When requesting quota, use the - **unit** value returned in the GET response in the request body of your PUT operation. - :type unit: str + :ivar unit: Quota limit units, such as Count and Bytes. When requesting quota, use the **unit** + value returned in the GET response in the request body of your PUT operation. + :vartype unit: str :ivar provisioning_state: The quota request status. Possible values include: "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.quota.models.QuotaRequestState @@ -940,8 +1082,8 @@ class SubRequest(msrest.serialization.Model): :vartype message: str :ivar sub_request_id: Quota request ID. :vartype sub_request_id: str - :param limit: Resource quota limit properties. - :type limit: ~azure.mgmt.quota.models.LimitJsonObject + :ivar limit: Resource quota limit properties. + :vartype limit: ~azure.mgmt.quota.models.LimitJsonObject """ _validation = { @@ -969,6 +1111,15 @@ def __init__( limit: Optional["LimitJsonObject"] = None, **kwargs ): + """ + :keyword name: Resource name. + :paramtype name: ~azure.mgmt.quota.models.ResourceName + :keyword unit: Quota limit units, such as Count and Bytes. When requesting quota, use the + **unit** value returned in the GET response in the request body of your PUT operation. + :paramtype unit: str + :keyword limit: Resource quota limit properties. + :paramtype limit: ~azure.mgmt.quota.models.LimitJsonObject + """ super(SubRequest, self).__init__(**kwargs) self.name = name self.resource_type = None @@ -982,11 +1133,11 @@ def __init__( class UsagesLimits(msrest.serialization.Model): """Quota limits. - :param value: List of quota limits. - :type value: list[~azure.mgmt.quota.models.CurrentUsagesBase] - :param next_link: The URI used to fetch the next page of quota limits. When there are no more + :ivar value: List of quota limits. + :vartype value: list[~azure.mgmt.quota.models.CurrentUsagesBase] + :ivar next_link: The URI used to fetch the next page of quota limits. When there are no more pages, this is null. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1001,6 +1152,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of quota limits. + :paramtype value: list[~azure.mgmt.quota.models.CurrentUsagesBase] + :keyword next_link: The URI used to fetch the next page of quota limits. When there are no more + pages, this is null. + :paramtype next_link: str + """ super(UsagesLimits, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1011,11 +1169,11 @@ class UsagesObject(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The usages value. - :type value: int - :param usages_type: The quota or usages limit types. Possible values include: "Individual", + :ivar value: Required. The usages value. + :vartype value: int + :ivar usages_type: The quota or usages limit types. Possible values include: "Individual", "Combined". - :type usages_type: str or ~azure.mgmt.quota.models.UsagesTypes + :vartype usages_type: str or ~azure.mgmt.quota.models.UsagesTypes """ _validation = { @@ -1034,6 +1192,13 @@ def __init__( usages_type: Optional[Union[str, "UsagesTypes"]] = None, **kwargs ): + """ + :keyword value: Required. The usages value. + :paramtype value: int + :keyword usages_type: The quota or usages limit types. Possible values include: "Individual", + "Combined". + :paramtype usages_type: str or ~azure.mgmt.quota.models.UsagesTypes + """ super(UsagesObject, self).__init__(**kwargs) self.value = value self.usages_type = usages_type @@ -1044,16 +1209,16 @@ class UsagesProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param usages: The quota limit properties for this resource. - :type usages: ~azure.mgmt.quota.models.UsagesObject + :ivar usages: The quota limit properties for this resource. + :vartype usages: ~azure.mgmt.quota.models.UsagesObject :ivar unit: The units for the quota usage, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. :vartype unit: str - :param name: Resource name provided by the resource provider. Use this property name when + :ivar name: Resource name provided by the resource provider. Use this property name when requesting quota. - :type name: ~azure.mgmt.quota.models.ResourceName - :param resource_type: The name of the resource type. - :type resource_type: str + :vartype name: ~azure.mgmt.quota.models.ResourceName + :ivar resource_type: The name of the resource type. + :vartype resource_type: str :ivar quota_period: The time period for the summary of the quota usage values. For example: *P1D (per one day)*\ PT1M (per one minute) *PT1S (per one second). @@ -1061,8 +1226,8 @@ class UsagesProperties(msrest.serialization.Model): :vartype quota_period: str :ivar is_quota_applicable: States if quota can be requested for this resource. :vartype is_quota_applicable: bool - :param properties: Additional properties for the specific resource provider. - :type properties: any + :ivar properties: Additional properties for the specific resource provider. + :vartype properties: any """ _validation = { @@ -1090,6 +1255,17 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword usages: The quota limit properties for this resource. + :paramtype usages: ~azure.mgmt.quota.models.UsagesObject + :keyword name: Resource name provided by the resource provider. Use this property name when + requesting quota. + :paramtype name: ~azure.mgmt.quota.models.ResourceName + :keyword resource_type: The name of the resource type. + :paramtype resource_type: str + :keyword properties: Additional properties for the specific resource provider. + :paramtype properties: any + """ super(UsagesProperties, self).__init__(**kwargs) self.usages = usages self.unit = None diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operation_operations.py index b13d9b64324e..31b0ca04a730 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operation_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operation_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Quota/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class QuotaOperationOperations(object): """QuotaOperationOperations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] + **kwargs: Any + ) -> Iterable["_models.OperationList"]: """GET quota operations. List all the operations supported by the Microsoft.Quota resource provider. @@ -64,30 +91,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,12 +124,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operations.py index 21e6bca8057c..5fb9a2b81b18 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_operations.py @@ -5,25 +5,176 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_name: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}') + path_format_arguments = { + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_name: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}') + path_format_arguments = { + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_name: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}') + path_format_arguments = { + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotas') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class QuotaOperations(object): """QuotaOperations operations. @@ -47,13 +198,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_name, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CurrentQuotaLimitBase" + resource_name: str, + scope: str, + **kwargs: Any + ) -> "_models.CurrentQuotaLimitBase": """Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new quota limit that can be submitted with a PUT request. @@ -80,89 +231,70 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_name=resource_name, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_name, # type: str - scope, # type: str - create_quota_request, # type: "_models.CurrentQuotaLimitBase" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CurrentQuotaLimitBase"] + resource_name: str, + scope: str, + create_quota_request: "_models.CurrentQuotaLimitBase", + **kwargs: Any + ) -> Optional["_models.CurrentQuotaLimitBase"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CurrentQuotaLimitBase"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + + request = build_create_or_update_request_initial( + resource_name=resource_name, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -172,16 +304,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_name, # type: str - scope, # type: str - create_quota_request, # type: "_models.CurrentQuotaLimitBase" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CurrentQuotaLimitBase"] + resource_name: str, + scope: str, + create_quota_request: "_models.CurrentQuotaLimitBase", + **kwargs: Any + ) -> LROPoller["_models.CurrentQuotaLimitBase"]: """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -210,15 +344,19 @@ def begin_create_or_update( :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CurrentQuotaLimitBase or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CurrentQuotaLimitBase or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] lro_delay = kwargs.pop( 'polling_interval', @@ -230,26 +368,21 @@ def begin_create_or_update( resource_name=resource_name, scope=scope, create_quota_request=create_quota_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -261,53 +394,42 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore def _update_initial( self, - resource_name, # type: str - scope, # type: str - create_quota_request, # type: "_models.CurrentQuotaLimitBase" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CurrentQuotaLimitBase"] + resource_name: str, + scope: str, + create_quota_request: "_models.CurrentQuotaLimitBase", + **kwargs: Any + ) -> Optional["_models.CurrentQuotaLimitBase"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CurrentQuotaLimitBase"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + + request = build_update_request_initial( + resource_name=resource_name, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -317,16 +439,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_name, # type: str - scope, # type: str - create_quota_request, # type: "_models.CurrentQuotaLimitBase" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CurrentQuotaLimitBase"] + resource_name: str, + scope: str, + create_quota_request: "_models.CurrentQuotaLimitBase", + **kwargs: Any + ) -> LROPoller["_models.CurrentQuotaLimitBase"]: """Update the quota limit for a specific resource to the specified value: @@ -354,15 +478,19 @@ def begin_update( :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either CurrentQuotaLimitBase or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either CurrentQuotaLimitBase or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.CurrentQuotaLimitBase] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] lro_delay = kwargs.pop( 'polling_interval', @@ -374,26 +502,21 @@ def begin_update( resource_name=resource_name, scope=scope, create_quota_request=create_quota_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -405,14 +528,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotas/{resourceName}'} # type: ignore + @distributed_trace def list( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.QuotaLimits"] + scope: str, + **kwargs: Any + ) -> Iterable["_models.QuotaLimits"]: """Get a list of current quota limits of all resources for the specified scope. The response from this GET operation can be leveraged to submit requests to update a quota. @@ -432,34 +556,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('QuotaLimits', pipeline_response) + deserialized = self._deserialize("QuotaLimits", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -472,12 +591,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_request_status_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_request_status_operations.py index bdd48a7f8d9e..73cb309b66cb 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_request_status_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_quota_request_status_operations.py @@ -5,23 +5,99 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotaRequests/{id}') + path_format_arguments = { + "id": _SERIALIZER.url("id", id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/quotaRequests') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class QuotaRequestStatusOperations(object): """QuotaRequestStatusOperations operations. @@ -45,13 +121,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.QuotaRequestDetails" + id: str, + scope: str, + **kwargs: Any + ) -> "_models.QuotaRequestDetails": """Get the quota request details and status by quota request ID for the resources of the resource provider at a specific location. The quota request ID **id** is returned in the response of the PUT operation. @@ -74,32 +150,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'id': self._serialize.url("id", id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + id=id, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaRequestDetails', pipeline_response) @@ -108,17 +174,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/quotaRequests/{id}'} # type: ignore + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.QuotaRequestDetailsList"] + scope: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.QuotaRequestDetailsList"]: """For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the **oData** filter to select quota requests. @@ -147,7 +215,8 @@ def list( **skiptoken** parameter that specifies a starting point to use for subsequent calls. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either QuotaRequestDetailsList or the result of cls(response) + :return: An iterator like instance of either QuotaRequestDetailsList or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.QuotaRequestDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -156,40 +225,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('QuotaRequestDetailsList', pipeline_response) + deserialized = self._deserialize("QuotaRequestDetailsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -202,12 +266,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_usages_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_usages_operations.py index 4cd7eac4e3a8..1ddc5cff2433 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_usages_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_usages_operations.py @@ -5,23 +5,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_name: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/usages/{resourceName}') + path_format_arguments = { + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-15-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Quota/usages') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class UsagesOperations(object): """UsagesOperations operations. @@ -45,13 +111,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_name, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CurrentUsagesBase" + resource_name: str, + scope: str, + **kwargs: Any + ) -> "_models.CurrentUsagesBase": """Get the current usage of a resource. :param resource_name: Resource name for a given resource provider. For example: @@ -77,50 +143,43 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_name=resource_name, + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentUsagesBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Quota/usages/{resourceName}'} # type: ignore + + @distributed_trace def list( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsagesLimits"] + scope: str, + **kwargs: Any + ) -> Iterable["_models.UsagesLimits"]: """Get a list of current usage for all resources for the scope specified. :param scope: The target Azure resource URI. For example, @@ -139,34 +198,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-15-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsagesLimits', pipeline_response) + deserialized = self._deserialize("UsagesLimits", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -179,12 +233,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )