diff --git a/sdk/quota/azure-mgmt-quota/_meta.json b/sdk/quota/azure-mgmt-quota/_meta.json index 74f21603f73a..2fcc50ef654a 100644 --- a/sdk/quota/azure-mgmt-quota/_meta.json +++ b/sdk/quota/azure-mgmt-quota/_meta.json @@ -1,11 +1,11 @@ { - "commit": "665e7c3b6f26b148b3c05e55602621bc293cc0a4", + "commit": "7055600b1d268953f3b308f6344ce64dd892c2d7", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.7", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/quota/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/quota/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/quota/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_quota_mgmt_client.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_quota_mgmt_client.py index c4db1c08ab11..bc0b1444817b 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_quota_mgmt_client.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_quota_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -178,7 +179,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "QuotaMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py index 2f781d740827..8139854b97bb 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 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 e32dc6ec4218..dfa6ee022f15 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 = "2.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_quota_mgmt_client.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_quota_mgmt_client.py index 97b28592ebcd..49912cf6b7b1 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_quota_mgmt_client.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_quota_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -180,7 +181,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "QuotaMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_operations.py index b64c3ca0b800..a5882adeb31a 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_limits_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +97,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaLimit :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,7 +121,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -133,7 +135,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaLimit", pipeline_response) + deserialized = self._deserialize("GroupQuotaLimit", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -180,7 +182,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,7 +202,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -216,7 +217,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_request_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_request_operations.py index 85b360e07db2..853744949161 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_request_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_limits_request_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_limits_request_operations import ( build_create_or_update_request, build_get_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,11 +71,10 @@ async def _create_or_update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any - ) -> Union[_models.SubmittedResourceRequestStatus, _models.LROResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,7 +87,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.SubmittedResourceRequestStatus, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -100,7 +104,6 @@ async def _create_or_update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, api_version=api_version, content_type=content_type, json=_json, @@ -108,33 +111,34 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - - if response.status_code == 201: + if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -147,7 +151,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[_models.SubmittedResourceRequestStatus] = None, *, content_type: str = "application/json", @@ -170,19 +173,16 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -192,7 +192,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", @@ -215,19 +214,16 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -237,7 +233,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: @@ -258,17 +253,14 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Is either a SubmittedResourceRequestStatus type or a IO[bytes] type. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either SubmittedResourceRequestStatus or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -285,7 +277,6 @@ async def begin_create_or_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -294,10 +285,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -326,11 +318,10 @@ async def _update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.SubmittedResourceRequestStatus]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,7 +334,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SubmittedResourceRequestStatus]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -360,7 +351,6 @@ async def _update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, api_version=api_version, content_type=content_type, json=_json, @@ -368,10 +358,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -379,15 +369,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -395,6 +385,8 @@ async def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -406,7 +398,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[_models.SubmittedResourceRequestStatus] = None, *, content_type: str = "application/json", @@ -429,8 +420,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus @@ -450,7 +439,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", @@ -473,8 +461,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: IO[bytes] @@ -494,7 +480,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: @@ -515,8 +500,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Is either a SubmittedResourceRequestStatus type or a IO[bytes] type. Default value is None. @@ -541,7 +524,6 @@ async def begin_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -550,10 +532,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -596,7 +579,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -618,7 +601,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -633,7 +615,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -679,7 +661,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubmittedResourceRequestStatusList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,7 +681,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -715,7 +696,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_location_settings_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_location_settings_operations.py index 51c9f3cbdb4f..d35712e0fee6 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_location_settings_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_location_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_location_settings_operations import ( build_create_or_update_request, build_get_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,8 +74,8 @@ async def _create_or_update_initial( location: str, location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, **kwargs: Any - ) -> Union[_models.GroupQuotasEnforcementResponse, _models.LROResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,7 +88,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.GroupQuotasEnforcementResponse, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -108,10 +113,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -119,14 +124,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -134,7 +140,7 @@ async def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -318,10 +324,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -351,8 +358,8 @@ async def _update_initial( location: str, location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.GroupQuotasEnforcementResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +372,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GroupQuotasEnforcementResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -390,10 +397,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -401,15 +408,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -417,6 +424,8 @@ async def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -596,10 +605,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -644,7 +654,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,7 +677,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -682,7 +691,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -719,7 +728,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotasEnforcementListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -738,7 +747,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -754,7 +762,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_operations.py index c985a4910a29..c3cdaf52380d 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_subscription_allocation_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -93,7 +96,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,7 +116,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -129,7 +131,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -192,7 +193,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocations :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,7 +217,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,7 +231,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SubscriptionQuotaAllocations", pipeline_response) + deserialized = self._deserialize("SubscriptionQuotaAllocations", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_request_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_request_operations.py index 1989ba53691e..0fb41cb33b98 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_request_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_request_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_subscription_allocation_request_operations import ( build_create_or_update_request, build_get_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +85,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +108,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,7 +122,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -165,7 +169,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QuotaAllocationRequestStatusList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,7 +190,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -202,7 +205,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -237,11 +239,10 @@ async def _create_or_update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any - ) -> Union[_models.QuotaAllocationRequestStatus, _models.LROResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,7 +255,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.QuotaAllocationRequestStatus, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -268,7 +269,6 @@ async def _create_or_update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -277,33 +277,34 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - - if response.status_code == 201: + if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -316,7 +317,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: _models.QuotaAllocationRequestStatus, *, content_type: str = "application/json", @@ -340,18 +340,15 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -361,7 +358,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", @@ -385,18 +381,15 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -406,7 +399,6 @@ async def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: @@ -428,17 +420,14 @@ async def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Is either a QuotaAllocationRequestStatus type or a IO[bytes] type. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus or IO[bytes] - :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of AsyncLROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -455,7 +444,6 @@ async def begin_create_or_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -464,10 +452,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -496,11 +485,10 @@ async def _update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any - ) -> Optional[_models.QuotaAllocationRequestStatus]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,7 +501,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.QuotaAllocationRequestStatus]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -527,7 +515,6 @@ async def _update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -536,10 +523,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -547,15 +534,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -563,6 +550,8 @@ async def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -574,7 +563,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: _models.QuotaAllocationRequestStatus, *, content_type: str = "application/json", @@ -598,8 +586,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -618,7 +604,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", @@ -642,8 +627,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -662,7 +645,6 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: @@ -684,8 +666,6 @@ async def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Is either a QuotaAllocationRequestStatus type or a IO[bytes] type. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus or @@ -710,7 +690,6 @@ async def begin_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -719,10 +698,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_requests_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_requests_operations.py index 5b09f29c1dd8..e598fd0948f0 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_requests_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_requests_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_subscription_requests_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +82,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaSubscriptionRequestStatusList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,7 +100,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -113,7 +115,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -167,7 +168,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,7 +190,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -204,7 +204,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaSubscriptionRequestStatus", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscriptions_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscriptions_operations.py index a887320125b8..7be394d2e334 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscriptions_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscriptions_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_subscriptions_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,8 +68,8 @@ def __init__(self, *args, **kwargs) -> None: async def _create_or_update_initial( self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> Union[_models.GroupQuotaSubscriptionId, _models.LROResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -76,7 +81,7 @@ async def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Union[_models.GroupQuotaSubscriptionId, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_create_or_update_request( management_group_id=management_group_id, @@ -86,10 +91,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -97,14 +102,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -112,7 +118,7 @@ async def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -159,10 +165,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -188,8 +195,8 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> Optional[_models.GroupQuotaSubscriptionId]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -201,7 +208,7 @@ async def _update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.GroupQuotaSubscriptionId]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_update_request( management_group_id=management_group_id, @@ -211,10 +218,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -222,15 +229,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -238,6 +245,8 @@ async def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -281,10 +290,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -308,10 +318,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +333,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( management_group_id=management_group_id, @@ -333,10 +343,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -344,6 +354,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -356,8 +370,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -386,7 +404,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, api_version=api_version, @@ -395,6 +413,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -437,7 +456,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionId :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,7 +478,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,7 +492,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -506,7 +524,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaSubscriptionIdList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +542,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -540,7 +557,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_usages_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_usages_operations.py index 07665a95fc0e..ab76764c17dd 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_usages_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_usages_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quota_usages_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +83,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,7 +103,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -116,7 +118,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quotas_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quotas_operations.py index b3e39f24093c..d30602d3e636 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quotas_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quotas_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_quotas_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,8 +73,8 @@ async def _create_or_update_initial( group_quota_name: str, group_quota_put_request_body: Optional[Union[_models.GroupQuotasEntity, IO[bytes]]] = None, **kwargs: Any - ) -> Union[_models.GroupQuotasEntity, _models.LROResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,7 +87,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.GroupQuotasEntity, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -105,10 +110,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -116,14 +121,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -131,7 +137,7 @@ async def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -265,10 +271,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -298,8 +305,8 @@ async def _update_initial( group_quota_name: str, group_quotas_patch_request_body: Optional[Union[_models.GroupQuotasEntityPatch, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.GroupQuotasEntity]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +319,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GroupQuotasEntity]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -335,10 +342,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -346,15 +353,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -362,6 +369,8 @@ async def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -498,10 +507,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -541,7 +551,7 @@ async def get(self, management_group_id: str, group_quota_name: str, **kwargs: A :rtype: ~azure.mgmt.quota.models.GroupQuotasEntity :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,7 +572,6 @@ async def get(self, management_group_id: str, group_quota_name: str, **kwargs: A headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -577,17 +586,17 @@ async def get(self, management_group_id: str, group_quota_name: str, **kwargs: A error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -599,7 +608,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( management_group_id=management_group_id, @@ -608,10 +617,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -619,6 +628,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -631,8 +644,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -661,7 +678,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, api_version=api_version, @@ -670,6 +687,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -712,7 +730,7 @@ def list(self, management_group_id: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -729,7 +747,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -745,7 +762,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 b0eb60fc342d..6a758aaad778 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._quota_operation_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +71,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationResponse"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,7 +87,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -100,7 +102,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 e5467d57f95b..cf3ea3881911 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ 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, build_get_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,14 +81,14 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: CurrentQuotaLimitBase or the result of cls(response) :rtype: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +109,6 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,7 +126,7 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -135,8 +139,8 @@ async def _create_or_update_initial( scope: str, create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CurrentQuotaLimitBase]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +153,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CurrentQuotaLimitBase]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -169,10 +173,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -180,13 +184,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -224,8 +230,8 @@ async def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Required. :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase @@ -269,8 +275,8 @@ async def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Required. :type create_quota_request: IO[bytes] @@ -312,8 +318,8 @@ async def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Is either a CurrentQuotaLimitBase type or a IO[bytes] type. Required. @@ -344,10 +350,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -378,8 +385,8 @@ async def _update_initial( scope: str, create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CurrentQuotaLimitBase]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,7 +399,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CurrentQuotaLimitBase]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -412,10 +419,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -423,13 +430,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -466,8 +475,8 @@ async def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Required. :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase @@ -510,8 +519,8 @@ async def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Required. :type create_quota_request: IO[bytes] @@ -552,8 +561,8 @@ async def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Is either a CurrentQuotaLimitBase type or a IO[bytes] type. Required. @@ -584,10 +593,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -620,8 +630,8 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentQuota :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: An iterator like instance of either CurrentQuotaLimitBase or the result of cls(response) @@ -634,7 +644,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentQuota api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QuotaLimits] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,7 +661,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -667,7 +676,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 61ea64967466..1d454d584440 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._quota_request_status_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,14 +67,14 @@ async def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestD :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: QuotaRequestDetails or the result of cls(response) :rtype: ~azure.mgmt.quota.models.QuotaRequestDetails :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,7 +95,6 @@ async def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestD headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -107,7 +109,7 @@ async def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestD error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaRequestDetails", pipeline_response) + deserialized = self._deserialize("QuotaRequestDetails", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -129,8 +131,8 @@ def list( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param filter: .. list-table:: :header-rows: 1 @@ -161,7 +163,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QuotaRequestDetailsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,7 +183,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -197,7 +198,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 dbc4f0050f1e..a708db60a68c 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._usages_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,14 +70,14 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: CurrentUsagesBase or the result of cls(response) :rtype: ~azure.mgmt.quota.models.CurrentUsagesBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,7 +98,6 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -113,7 +115,7 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CurrentUsagesBase", pipeline_response) + deserialized = self._deserialize("CurrentUsagesBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -127,8 +129,8 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentUsage :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: An iterator like instance of either CurrentUsagesBase or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.CurrentUsagesBase] @@ -140,7 +142,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentUsage api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesLimits] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -157,7 +159,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -173,7 +174,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 e5ba7140afe0..268a5717371e 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 @@ -742,6 +742,8 @@ class GroupQuotaRequestBaseProperties(_serialization.Model): :vartype name: ~azure.mgmt.quota.models.GroupQuotaRequestBasePropertiesName :ivar region: Location/Azure region for the quota requested for resource. :vartype region: str + :ivar resource_name: The resource name, such as SKU name. + :vartype resource_name: str :ivar comments: GroupQuota Request comments and details for request. This is optional paramter to provide more details related to the requested resource. :vartype comments: str @@ -755,6 +757,7 @@ class GroupQuotaRequestBaseProperties(_serialization.Model): "limit": {"key": "limit", "type": "int"}, "name": {"key": "name", "type": "GroupQuotaRequestBasePropertiesName"}, "region": {"key": "region", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, "comments": {"key": "comments", "type": "str"}, } @@ -763,6 +766,7 @@ def __init__( *, limit: Optional[int] = None, region: Optional[str] = None, + resource_name: Optional[str] = None, comments: Optional[str] = None, **kwargs: Any ) -> None: @@ -772,6 +776,8 @@ def __init__( :paramtype limit: int :keyword region: Location/Azure region for the quota requested for resource. :paramtype region: str + :keyword resource_name: The resource name, such as SKU name. + :paramtype resource_name: str :keyword comments: GroupQuota Request comments and details for request. This is optional paramter to provide more details related to the requested resource. :paramtype comments: str @@ -780,6 +786,7 @@ def __init__( self.limit = limit self.name = None self.region = region + self.resource_name = resource_name self.comments = comments @@ -1720,6 +1727,8 @@ class QuotaAllocationRequestBaseProperties(_serialization.Model): :vartype name: ~azure.mgmt.quota.models.QuotaAllocationRequestBasePropertiesName :ivar region: The location for which the subscription is allocated. :vartype region: str + :ivar resource_name: The resource name, such as SKU name. + :vartype resource_name: str """ _validation = { @@ -1730,20 +1739,31 @@ class QuotaAllocationRequestBaseProperties(_serialization.Model): "limit": {"key": "limit", "type": "int"}, "name": {"key": "name", "type": "QuotaAllocationRequestBasePropertiesName"}, "region": {"key": "region", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } - def __init__(self, *, limit: Optional[int] = None, region: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + limit: Optional[int] = None, + region: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword limit: The new quota limit for the subscription. The incremental quota will be allocated from pre-approved group quota. :paramtype limit: int :keyword region: The location for which the subscription is allocated. :paramtype region: str + :keyword resource_name: The resource name, such as SKU name. + :paramtype resource_name: str """ super().__init__(**kwargs) self.limit = limit self.name = None self.region = region + self.resource_name = resource_name class QuotaAllocationRequestBasePropertiesName(_serialization.Model): @@ -1980,7 +2000,7 @@ class QuotaProperties(_serialization.Model): :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) + *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 @@ -2137,7 +2157,7 @@ class QuotaRequestOneResourceProperties(_serialization.Model): # pylint: disabl :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) + *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 @@ -2333,7 +2353,7 @@ class QuotaRequestStatusDetails(_serialization.Model): :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) + *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 @@ -3259,7 +3279,7 @@ class UsagesProperties(_serialization.Model): :ivar resource_type: The name of the resource type. Optional field. :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) + *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 diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_operations.py index fc78bb311bd1..b4f6531760e0 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -187,7 +190,7 @@ def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaLimit :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,7 +214,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,7 +228,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaLimit", pipeline_response) + deserialized = self._deserialize("GroupQuotaLimit", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -273,7 +275,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -293,7 +295,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -309,7 +310,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_request_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_request_operations.py index 16dfaa1c381c..30fbeb3a0773 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_request_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_limits_request_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_create_or_update_request( - management_group_id: str, group_quota_name: str, resource_provider_name: str, resource_name: str, **kwargs: Any + management_group_id: str, group_quota_name: str, resource_provider_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -52,7 +57,7 @@ def build_create_or_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaRequests/{resourceName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/createLimitRequest", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -67,9 +72,6 @@ def build_create_or_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -98,7 +100,7 @@ def build_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaRequests/{resourceName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/createLimitRequest", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -113,9 +115,6 @@ def build_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? Union[_models.SubmittedResourceRequestStatus, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,7 +246,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.SubmittedResourceRequestStatus, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -265,7 +263,6 @@ def _create_or_update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, api_version=api_version, content_type=content_type, json=_json, @@ -273,33 +270,34 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - - if response.status_code == 201: + if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -312,7 +310,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[_models.SubmittedResourceRequestStatus] = None, *, content_type: str = "application/json", @@ -335,18 +332,15 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] - or ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -356,7 +350,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", @@ -379,18 +372,15 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] - or ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -400,7 +390,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[_models.SubmittedResourceRequestStatus]: @@ -421,16 +410,13 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Is either a SubmittedResourceRequestStatus type or a IO[bytes] type. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus or IO[bytes] - :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) + :return: An instance of LROPoller that returns either SubmittedResourceRequestStatus or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] - or ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -447,7 +433,6 @@ def begin_create_or_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -456,10 +441,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -488,11 +474,10 @@ def _update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.SubmittedResourceRequestStatus]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,7 +490,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SubmittedResourceRequestStatus]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -522,7 +507,6 @@ def _update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, api_version=api_version, content_type=content_type, json=_json, @@ -530,10 +514,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -541,15 +525,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -557,6 +541,8 @@ def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -568,7 +554,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[_models.SubmittedResourceRequestStatus] = None, *, content_type: str = "application/json", @@ -591,8 +576,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus @@ -611,7 +594,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", @@ -634,8 +616,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Default value is None. :type group_quota_request: IO[bytes] @@ -654,7 +634,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, group_quota_request: Optional[Union[_models.SubmittedResourceRequestStatus, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[_models.SubmittedResourceRequestStatus]: @@ -675,8 +654,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param group_quota_request: The GroupQuotaRequest body details for specific resourceProvider/location/resources. Is either a SubmittedResourceRequestStatus type or a IO[bytes] type. Default value is None. @@ -700,7 +677,6 @@ def begin_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -709,10 +685,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -755,7 +732,7 @@ def get( :rtype: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -777,7 +754,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -792,7 +768,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) + deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -837,7 +813,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubmittedResourceRequestStatusList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +833,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -873,7 +848,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_location_settings_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_location_settings_operations.py index dcacb1e73bd7..4d9b3029fecf 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_location_settings_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_location_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -235,8 +240,8 @@ def _create_or_update_initial( location: str, location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, **kwargs: Any - ) -> Union[_models.GroupQuotasEnforcementResponse, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +254,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.GroupQuotasEnforcementResponse, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -274,10 +279,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -285,14 +290,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -300,7 +306,7 @@ def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -481,10 +487,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -514,8 +521,8 @@ def _update_initial( location: str, location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.GroupQuotasEnforcementResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,7 +535,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GroupQuotasEnforcementResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -553,10 +560,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -564,15 +571,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -580,6 +587,8 @@ def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -756,10 +765,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -804,7 +814,7 @@ def get( :rtype: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -827,7 +837,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -842,7 +851,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response) + deserialized = self._deserialize("GroupQuotasEnforcementResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -878,7 +887,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotasEnforcementListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -897,7 +906,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -913,7 +921,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_operations.py index 825c0b450d30..f4b6a117683a 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -175,7 +178,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,7 +198,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -211,7 +213,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -274,7 +275,7 @@ def get( :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocations :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,7 +299,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -313,7 +313,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SubscriptionQuotaAllocations", pipeline_response) + deserialized = self._deserialize("SubscriptionQuotaAllocations", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_request_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_request_operations.py index aabf4db81820..a6bd4e72bb5f 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_request_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_request_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -124,12 +129,7 @@ def build_list_request( def build_create_or_update_request( - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - resource_name: str, - subscription_id: str, - **kwargs: Any + management_group_id: str, group_quota_name: str, resource_provider_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -141,7 +141,7 @@ def build_create_or_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/quotaAllocationRequests/{resourceName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/createAllocationRequest", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -157,9 +157,6 @@ def build_create_or_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -193,7 +185,7 @@ def build_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/quotaAllocationRequests/{resourceName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/createAllocationRequest", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -209,9 +201,6 @@ def build_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? Union[_models.QuotaAllocationRequestStatus, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +423,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.QuotaAllocationRequestStatus, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -452,7 +437,6 @@ def _create_or_update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -461,33 +445,34 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - - if response.status_code == 201: + if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -500,7 +485,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: _models.QuotaAllocationRequestStatus, *, content_type: str = "application/json", @@ -524,17 +508,14 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] + :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -544,7 +525,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", @@ -568,17 +548,14 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] + :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -588,7 +565,6 @@ def begin_create_or_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.QuotaAllocationRequestStatus]: @@ -610,16 +586,13 @@ def begin_create_or_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Is either a QuotaAllocationRequestStatus type or a IO[bytes] type. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus or IO[bytes] - :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] or - ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.LROResponse] + :return: An instance of LROPoller that returns either QuotaAllocationRequestStatus or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -636,7 +609,6 @@ def begin_create_or_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -645,10 +617,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -677,11 +650,10 @@ def _update_initial( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any - ) -> Optional[_models.QuotaAllocationRequestStatus]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.QuotaAllocationRequestStatus]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -708,7 +680,6 @@ def _update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -717,10 +688,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -728,15 +699,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -744,6 +715,8 @@ def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -755,7 +728,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: _models.QuotaAllocationRequestStatus, *, content_type: str = "application/json", @@ -779,8 +751,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -798,7 +768,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", @@ -822,8 +791,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Required. :type allocate_quota_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -841,7 +808,6 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.QuotaAllocationRequestStatus]: @@ -863,8 +829,6 @@ def begin_update( :param resource_provider_name: The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API. Required. :type resource_provider_name: str - :param resource_name: Resource name. Required. - :type resource_name: str :param allocate_quota_request: Quota requests payload. Is either a QuotaAllocationRequestStatus type or a IO[bytes] type. Required. :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus or @@ -888,7 +852,6 @@ def begin_update( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -897,10 +860,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py index 14fb393141c7..d95066a832fa 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -148,7 +151,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaSubscriptionRequestStatusList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,7 +169,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -182,7 +184,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -236,7 +237,7 @@ def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,7 +259,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -273,7 +273,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaSubscriptionRequestStatus", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionRequestStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscriptions_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscriptions_operations.py index b4f6518c7d68..247be0c1e25a 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscriptions_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscriptions_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -15,13 +16,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -231,8 +236,8 @@ def __init__(self, *args, **kwargs): def _create_or_update_initial( self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> Union[_models.GroupQuotaSubscriptionId, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +249,7 @@ def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Union[_models.GroupQuotaSubscriptionId, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_create_or_update_request( management_group_id=management_group_id, @@ -254,10 +259,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -265,14 +270,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -280,7 +286,7 @@ def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -327,10 +333,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -354,10 +361,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _update_initial( - self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> Optional[_models.GroupQuotaSubscriptionId]: - error_map = { + def _update_initial(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +374,7 @@ def _update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.GroupQuotaSubscriptionId]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_update_request( management_group_id=management_group_id, @@ -379,10 +384,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -390,15 +395,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -406,6 +411,8 @@ def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -449,10 +456,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -476,10 +484,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +497,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( management_group_id=management_group_id, @@ -501,10 +507,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -512,6 +518,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -524,8 +534,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> LROPoller[None]: @@ -552,7 +566,7 @@ def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, api_version=api_version, @@ -561,6 +575,7 @@ def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -601,7 +616,7 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionId :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +638,6 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -638,7 +652,7 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response) + deserialized = self._deserialize("GroupQuotaSubscriptionId", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -669,7 +683,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaSubscriptionIdList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -687,7 +701,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -703,7 +716,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_usages_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_usages_operations.py index 3379fe14f2b8..45678c9d905b 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_usages_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_usages_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -124,7 +127,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceUsageList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -144,7 +147,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -160,7 +162,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quotas_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quotas_operations.py index 1b15e85d1c91..cfc2a85bbf76 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quotas_operations.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quotas_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -227,8 +232,8 @@ def _create_or_update_initial( group_quota_name: str, group_quota_put_request_body: Optional[Union[_models.GroupQuotasEntity, IO[bytes]]] = None, **kwargs: Any - ) -> Union[_models.GroupQuotasEntity, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,7 +246,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Union[_models.GroupQuotasEntity, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -264,10 +269,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -275,14 +280,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -290,7 +296,7 @@ def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("LROResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -424,10 +430,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -457,8 +464,8 @@ def _update_initial( group_quota_name: str, group_quotas_patch_request_body: Optional[Union[_models.GroupQuotasEntityPatch, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.GroupQuotasEntity]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,7 +478,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GroupQuotasEntity]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -494,10 +501,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -505,15 +512,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) - if response.status_code == 202: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -521,6 +528,8 @@ def _update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -657,10 +666,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -700,7 +710,7 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.quota.models.GroupQuotasEntity :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -721,7 +731,6 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -736,17 +745,15 @@ def get(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GroupQuotasEntity", pipeline_response) + deserialized = self._deserialize("GroupQuotasEntity", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, group_quota_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,7 +765,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( management_group_id=management_group_id, @@ -767,10 +774,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -778,6 +785,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -790,8 +801,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs: Any) -> LROPoller[None]: @@ -818,7 +833,7 @@ def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, api_version=api_version, @@ -827,6 +842,7 @@ def begin_delete(self, management_group_id: str, group_quota_name: str, **kwargs params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -869,7 +885,7 @@ def list(self, management_group_id: str, **kwargs: Any) -> Iterable["_models.Gro api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupQuotaList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +902,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -902,7 +917,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 265f3bd184d4..76911aec3926 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.OperationResponse"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,7 +109,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -122,7 +124,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 f22065db1050..7dee0e5c81f4 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -178,14 +183,14 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentQ :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: CurrentQuotaLimitBase or the result of cls(response) :rtype: ~azure.mgmt.quota.models.CurrentQuotaLimitBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,7 +211,6 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentQ headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -224,7 +228,7 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentQ response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -237,8 +241,8 @@ def _create_or_update_initial( scope: str, create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CurrentQuotaLimitBase]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,7 +255,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CurrentQuotaLimitBase]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -271,10 +275,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -282,13 +286,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -326,8 +332,8 @@ def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Required. :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase @@ -371,8 +377,8 @@ def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Required. :type create_quota_request: IO[bytes] @@ -414,8 +420,8 @@ def begin_create_or_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota request payload. Is either a CurrentQuotaLimitBase type or a IO[bytes] type. Required. @@ -446,10 +452,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -479,8 +486,8 @@ def _update_initial( scope: str, create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CurrentQuotaLimitBase]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,7 +500,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CurrentQuotaLimitBase]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -513,10 +520,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -524,13 +531,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -567,8 +576,8 @@ def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Required. :type create_quota_request: ~azure.mgmt.quota.models.CurrentQuotaLimitBase @@ -611,8 +620,8 @@ def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Required. :type create_quota_request: IO[bytes] @@ -653,8 +662,8 @@ def begin_update( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param create_quota_request: Quota requests payload. Is either a CurrentQuotaLimitBase type or a IO[bytes] type. Required. @@ -685,10 +694,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response) + deserialized = self._deserialize("CurrentQuotaLimitBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -720,8 +730,8 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentQuotaLimit :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: An iterator like instance of either CurrentQuotaLimitBase or the result of cls(response) @@ -734,7 +744,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentQuotaLimit api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QuotaLimits] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -751,7 +761,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -767,7 +776,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 680f5ddea375..89dbee4e9685 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -128,14 +131,14 @@ def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestDetails :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: QuotaRequestDetails or the result of cls(response) :rtype: ~azure.mgmt.quota.models.QuotaRequestDetails :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,7 +159,6 @@ def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestDetails headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -171,7 +173,7 @@ def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestDetails error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaRequestDetails", pipeline_response) + deserialized = self._deserialize("QuotaRequestDetails", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -193,8 +195,8 @@ def list( :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :param filter: .. list-table:: :header-rows: 1 @@ -225,7 +227,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.QuotaRequestDetailsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +247,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -261,7 +262,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 08d7c591b503..754e288b8dd2 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -118,14 +121,14 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentU :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: CurrentUsagesBase or the result of cls(response) :rtype: ~azure.mgmt.quota.models.CurrentUsagesBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,7 +149,6 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentU headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -164,7 +166,7 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentU response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CurrentUsagesBase", pipeline_response) + deserialized = self._deserialize("CurrentUsagesBase", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -178,8 +180,8 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentUsagesBase :param scope: The target Azure resource URI. For example, ``/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/``. This is the target Azure resource URI for the List GET operation. If a ``{resourceName}`` is - added after ``/quotas``\ , then it's the target Azure resource URI in the GET operation for the - specific resource. Required. + added after ``/quotas``\\ , then it's the target Azure resource URI in the GET operation for + the specific resource. Required. :type scope: str :return: An iterator like instance of either CurrentUsagesBase or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.CurrentUsagesBase] @@ -191,7 +193,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentUsagesBase api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsagesLimits] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +210,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -224,7 +225,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/get_group_quota_limits_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/get_group_quota_limits_compute.py new file mode 100644 index 000000000000..d9bf05d20d7f --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/get_group_quota_limits_compute.py @@ -0,0 +1,45 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python get_group_quota_limits_compute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.group_quota_limits.get( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + resource_provider_name="Microsoft.Compute", + resource_name="cores", + filter="location eq westus", + ) + print(response) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/GetGroupQuotaLimits-Compute.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/list_group_quota_limits_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/list_group_quota_limits_compute.py new file mode 100644 index 000000000000..312e0e5534c0 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/list_group_quota_limits_compute.py @@ -0,0 +1,45 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python list_group_quota_limits_compute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.group_quota_limits.list( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + resource_provider_name="Microsoft.Compute", + filter="location eq westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/ListGroupQuotaLimits-Compute.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_get.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_get.py new file mode 100644 index 000000000000..89aaf244187f --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_get.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python group_quota_limits_requests_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.group_quota_limits_request.get( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + request_id_parameter="requestId", + ) + print(response) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimitsRequests/GroupQuotaLimitsRequests_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_list.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_list.py new file mode 100644 index 000000000000..4ac011c0f6fb --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_list.py @@ -0,0 +1,45 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python group_quota_limits_requests_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.group_quota_limits_request.list( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + resource_provider_name="Microsoft.Compute", + filter="location eq westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimitsRequests/GroupQuotaLimitsRequests_List.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/patch_group_quota_limits_requests_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/patch_group_quota_limits_requests_compute.py index f261d97f998f..de84f35201b1 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/patch_group_quota_limits_requests_compute.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/patch_group_quota_limits_requests_compute.py @@ -34,7 +34,6 @@ def main(): management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", ).result() print(response) diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/put_group_quota_limits_requests_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/put_group_quota_limits_requests_compute.py index ff3fc743b593..22916ed980d0 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/put_group_quota_limits_requests_compute.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/put_group_quota_limits_requests_compute.py @@ -34,7 +34,6 @@ def main(): management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", ).result() print(response) diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/patch_compute_quota_request.py b/sdk/quota/azure-mgmt-quota/generated_samples/patch_compute_quota_request.py index dcb3e0516a0d..7c54939b559c 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/patch_compute_quota_request.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/patch_compute_quota_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/patch_network_one_sku_quota_request.py b/sdk/quota/azure-mgmt-quota/generated_samples/patch_network_one_sku_quota_request.py index 2b0798c1a9cb..0fc5fc57074a 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/patch_network_one_sku_quota_request.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/patch_network_one_sku_quota_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/put_compute_one_sku_quota_request.py b/sdk/quota/azure-mgmt-quota/generated_samples/put_compute_one_sku_quota_request.py index 557b1c01aa9c..471e410ae67f 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/put_compute_one_sku_quota_request.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/put_compute_one_sku_quota_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/put_machine_learning_services_quota_request_low_priority.py b/sdk/quota/azure-mgmt-quota/generated_samples/put_machine_learning_services_quota_request_low_priority.py index baa5790f1623..2bf3abd1c4eb 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/put_machine_learning_services_quota_request_low_priority.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/put_machine_learning_services_quota_request_low_priority.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request.py b/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request.py index 7ac218cb05dc..a2095f320c3b 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request_standard_sku_public_ip_addresses.py b/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request_standard_sku_public_ip_addresses.py index 166bb7ec74b2..9b66c2fa1540 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request_standard_sku_public_ip_addresses.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/put_network_one_sku_quota_request_standard_sku_public_ip_addresses.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_get_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_get_compute.py new file mode 100644 index 000000000000..29ab740bd716 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_get_compute.py @@ -0,0 +1,44 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python subscription_quota_allocation_get_compute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.group_quota_subscription_allocation.get( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + resource_name="standardav2family", + filter="provider eq Microsoft.Compute & location eq westus", + ) + print(response) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_Get-Compute.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_list_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_list_compute.py new file mode 100644 index 000000000000..bca641440514 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_list_compute.py @@ -0,0 +1,44 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python subscription_quota_allocation_list_compute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.group_quota_subscription_allocation.list( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + filter="provider eq Microsoft.Compute & location eq westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_List-Compute.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/patch_subscription_quota_allocation_request_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/patch_subscription_quota_allocation_request_compute.py index 11939d20179b..680bf42cfd47 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/patch_subscription_quota_allocation_request_compute.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/patch_subscription_quota_allocation_request_compute.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient @@ -36,8 +34,13 @@ def main(): management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", - allocate_quota_request={"properties": {"requestedResource": {"properties": {"limit": 10, "region": "westus"}}}}, + allocate_quota_request={ + "properties": { + "requestedResource": { + "properties": {"limit": 10, "region": "westus", "resourceName": "standardav2family"} + } + } + }, ).result() print(response) diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py index 403032ea4440..f54ef089aac4 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.quota import QuotaMgmtClient @@ -36,8 +34,13 @@ def main(): management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", - allocate_quota_request={"properties": {"requestedResource": {"properties": {"limit": 10, "region": "westus"}}}}, + allocate_quota_request={ + "properties": { + "requestedResource": { + "properties": {"limit": 10, "region": "westus", "resourceName": "standardav2family"} + } + } + }, ).result() print(response) diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py new file mode 100644 index 000000000000..8800c3bce4e3 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py @@ -0,0 +1,45 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python subscription_quota_allocation_requests_list_compute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.group_quota_subscription_allocation_request.list( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + resource_provider_name="Microsoft.Compute", + filter="location eq westus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_List-Compute.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_get.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_get.py new file mode 100644 index 000000000000..1cd53c0a0649 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_get.py @@ -0,0 +1,43 @@ +# 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.identity import DefaultAzureCredential + +from azure.mgmt.quota import QuotaMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-quota +# USAGE + python subscription_requests_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = QuotaMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.group_quota_subscription_requests.get( + management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", + group_quota_name="groupquota1", + request_id_parameter="00000000-0000-0000-0000-000000000000", + ) + print(response) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/conftest.py b/sdk/quota/azure-mgmt-quota/generated_tests/conftest.py new file mode 100644 index 000000000000..2bc64b98d9a0 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + quotamgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + quotamgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + quotamgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + quotamgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=quotamgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=quotamgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=quotamgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=quotamgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations.py new file mode 100644 index 000000000000..b6307194cb3d --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations.py @@ -0,0 +1,48 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLimitsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_limits.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + resource_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_limits.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations_async.py new file mode 100644 index 000000000000..dbb63381d1a0 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_operations_async.py @@ -0,0 +1,49 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLimitsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_limits.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + resource_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_limits.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations.py new file mode 100644 index 000000000000..59bf76ea13cf --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations.py @@ -0,0 +1,72 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLimitsRequestOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.group_quota_limits_request.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.group_quota_limits_request.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_limits_request.get( + management_group_id="str", + group_quota_name="str", + request_id_parameter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_limits_request.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations_async.py new file mode 100644 index 000000000000..3c1ed6da294f --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations_async.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLimitsRequestOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.group_quota_limits_request.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.group_quota_limits_request.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_limits_request.get( + management_group_id="str", + group_quota_name="str", + request_id_parameter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_limits_request.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations.py new file mode 100644 index 000000000000..e17d9de664c9 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLocationSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.group_quota_location_settings.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.group_quota_location_settings.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_location_settings.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_location_settings.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations_async.py new file mode 100644 index 000000000000..55150b59754b --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_location_settings_operations_async.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaLocationSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.group_quota_location_settings.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.group_quota_location_settings.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_location_settings.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_location_settings.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations.py new file mode 100644 index 000000000000..dffc3e192786 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations.py @@ -0,0 +1,46 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionAllocationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_subscription_allocation.list( + management_group_id="str", + group_quota_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_subscription_allocation.get( + management_group_id="str", + group_quota_name="str", + resource_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations_async.py new file mode 100644 index 000000000000..46819ca27868 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_operations_async.py @@ -0,0 +1,47 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionAllocationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_subscription_allocation.list( + management_group_id="str", + group_quota_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_subscription_allocation.get( + management_group_id="str", + group_quota_name="str", + resource_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations.py new file mode 100644 index 000000000000..89f579ec4bb8 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations.py @@ -0,0 +1,124 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionAllocationRequestOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_subscription_allocation_request.get( + management_group_id="str", + group_quota_name="str", + allocation_id="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_subscription_allocation_request.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.group_quota_subscription_allocation_request.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "faultCode": "str", + "provisioningState": "str", + "requestSubmitTime": "2020-02-20 00:00:00", + "requestedResource": { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "region": "str", + "resourceName": "str", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.group_quota_subscription_allocation_request.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "faultCode": "str", + "provisioningState": "str", + "requestSubmitTime": "2020-02-20 00:00:00", + "requestedResource": { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "region": "str", + "resourceName": "str", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations_async.py new file mode 100644 index 000000000000..3d1abb8a8e1b --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations_async.py @@ -0,0 +1,129 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionAllocationRequestOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_subscription_allocation_request.get( + management_group_id="str", + group_quota_name="str", + allocation_id="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_subscription_allocation_request.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + filter="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.group_quota_subscription_allocation_request.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "faultCode": "str", + "provisioningState": "str", + "requestSubmitTime": "2020-02-20 00:00:00", + "requestedResource": { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "region": "str", + "resourceName": "str", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.group_quota_subscription_allocation_request.begin_update( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "faultCode": "str", + "provisioningState": "str", + "requestSubmitTime": "2020-02-20 00:00:00", + "requestedResource": { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "region": "str", + "resourceName": "str", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations.py new file mode 100644 index 000000000000..288060267b59 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations.py @@ -0,0 +1,44 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionRequestsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_subscription_requests.list( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_subscription_requests.get( + management_group_id="str", + group_quota_name="str", + request_id_parameter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations_async.py new file mode 100644 index 000000000000..c7e5b3d73859 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_requests_operations_async.py @@ -0,0 +1,45 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionRequestsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_subscription_requests.list( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_subscription_requests.get( + management_group_id="str", + group_quota_name="str", + request_id_parameter="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations.py new file mode 100644 index 000000000000..c7ca4ff80702 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.group_quota_subscriptions.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.group_quota_subscriptions.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.group_quota_subscriptions.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quota_subscriptions.get( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_subscriptions.list( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations_async.py new file mode 100644 index 000000000000..0e4efdb9d818 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscriptions_operations_async.py @@ -0,0 +1,86 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaSubscriptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.group_quota_subscriptions.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.group_quota_subscriptions.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.group_quota_subscriptions.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quota_subscriptions.get( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_subscriptions.list( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations.py new file mode 100644 index 000000000000..0dca5bfcfe19 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quota_usages.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations_async.py new file mode 100644 index 000000000000..219d179fef4e --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_usages_operations_async.py @@ -0,0 +1,34 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotaUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quota_usages.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations.py new file mode 100644 index 000000000000..ed8e05858d90 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations.py @@ -0,0 +1,78 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.group_quotas.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.group_quotas.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group_quotas.get( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.group_quotas.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_quotas.list( + management_group_id="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations_async.py new file mode 100644 index 000000000000..f669b1d176f5 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quotas_operations_async.py @@ -0,0 +1,85 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtGroupQuotasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.group_quotas.begin_create_or_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.group_quotas.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group_quotas.get( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.group_quotas.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_quotas.list( + management_group_id="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations.py new file mode 100644 index 000000000000..adc66f5648d3 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaOperationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.quota_operation.list( + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations_async.py new file mode 100644 index 000000000000..8f0721044857 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operation_operations_async.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaOperationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.quota_operation.list( + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations.py new file mode 100644 index 000000000000..c52723603538 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations.py @@ -0,0 +1,94 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.quota.get( + resource_name="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.quota.begin_create_or_update( + resource_name="str", + scope="str", + create_quota_request={ + "id": "str", + "name": "str", + "properties": { + "isQuotaApplicable": bool, + "limit": "limit_json_object", + "name": {"localizedValue": "str", "value": "str"}, + "properties": {}, + "quotaPeriod": "str", + "resourceType": "str", + "unit": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.quota.begin_update( + resource_name="str", + scope="str", + create_quota_request={ + "id": "str", + "name": "str", + "properties": { + "isQuotaApplicable": bool, + "limit": "limit_json_object", + "name": {"localizedValue": "str", "value": "str"}, + "properties": {}, + "quotaPeriod": "str", + "resourceType": "str", + "unit": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.quota.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations_async.py new file mode 100644 index 000000000000..fc83d5be1ab6 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_operations_async.py @@ -0,0 +1,99 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.quota.get( + resource_name="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.quota.begin_create_or_update( + resource_name="str", + scope="str", + create_quota_request={ + "id": "str", + "name": "str", + "properties": { + "isQuotaApplicable": bool, + "limit": "limit_json_object", + "name": {"localizedValue": "str", "value": "str"}, + "properties": {}, + "quotaPeriod": "str", + "resourceType": "str", + "unit": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.quota.begin_update( + resource_name="str", + scope="str", + create_quota_request={ + "id": "str", + "name": "str", + "properties": { + "isQuotaApplicable": bool, + "limit": "limit_json_object", + "name": {"localizedValue": "str", "value": "str"}, + "properties": {}, + "quotaPeriod": "str", + "resourceType": "str", + "unit": "str", + }, + "type": "str", + }, + api_version="2023-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.quota.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations.py new file mode 100644 index 000000000000..a7142c312eae --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations.py @@ -0,0 +1,42 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaRequestStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.quota_request_status.get( + id="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.quota_request_status.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations_async.py new file mode 100644 index 000000000000..0ed73e7add1d --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_quota_request_status_operations_async.py @@ -0,0 +1,43 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtQuotaRequestStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.quota_request_status.get( + id="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.quota_request_status.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations.py new file mode 100644 index 000000000000..c3b11cf784c7 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations.py @@ -0,0 +1,42 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.usages.get( + resource_name="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.usages.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations_async.py b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations_async.py new file mode 100644 index 000000000000..41028ba0d2a6 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_usages_operations_async.py @@ -0,0 +1,43 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.quota.aio import QuotaMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuotaMgmtUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(QuotaMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.usages.get( + resource_name="str", + scope="str", + api_version="2023-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.usages.list( + scope="str", + api_version="2023-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/quota/azure-mgmt-quota/setup.py b/sdk/quota/azure-mgmt-quota/setup.py index ba4638cbced9..e38b1517297a 100644 --- a/sdk/quota/azure-mgmt-quota/setup.py +++ b/sdk/quota/azure-mgmt-quota/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],