diff --git a/sdk/quota/azure-mgmt-quota/_meta.json b/sdk/quota/azure-mgmt-quota/_meta.json index 74f21603f73a..321fd5faaa85 100644 --- a/sdk/quota/azure-mgmt-quota/_meta.json +++ b/sdk/quota/azure-mgmt-quota/_meta.json @@ -1,11 +1,11 @@ { - "commit": "665e7c3b6f26b148b3c05e55602621bc293cc0a4", + "commit": "213638e89dc6c0d7d4d6244c7a079532afe5e3fa", "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/_configuration.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py index eeb2629a6960..d1f626f2255e 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py @@ -28,13 +28,13 @@ class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attribu :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-15-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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..f86061f3024a 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 @@ -50,19 +51,19 @@ class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too :ivar group_quota_subscription_requests: GroupQuotaSubscriptionRequestsOperations operations :vartype group_quota_subscription_requests: azure.mgmt.quota.operations.GroupQuotaSubscriptionRequestsOperations - :ivar group_quota_limits: GroupQuotaLimitsOperations operations - :vartype group_quota_limits: azure.mgmt.quota.operations.GroupQuotaLimitsOperations :ivar group_quota_limits_request: GroupQuotaLimitsRequestOperations operations :vartype group_quota_limits_request: azure.mgmt.quota.operations.GroupQuotaLimitsRequestOperations - :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations - operations - :vartype group_quota_subscription_allocation: - azure.mgmt.quota.operations.GroupQuotaSubscriptionAllocationOperations + :ivar group_quota_limits: GroupQuotaLimitsOperations operations + :vartype group_quota_limits: azure.mgmt.quota.operations.GroupQuotaLimitsOperations :ivar group_quota_subscription_allocation_request: GroupQuotaSubscriptionAllocationRequestOperations operations :vartype group_quota_subscription_allocation_request: azure.mgmt.quota.operations.GroupQuotaSubscriptionAllocationRequestOperations + :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations + operations + :vartype group_quota_subscription_allocation: + azure.mgmt.quota.operations.GroupQuotaSubscriptionAllocationOperations :ivar group_quota_usages: GroupQuotaUsagesOperations operations :vartype group_quota_usages: azure.mgmt.quota.operations.GroupQuotaUsagesOperations :ivar group_quota_location_settings: GroupQuotaLocationSettingsOperations operations @@ -82,7 +83,7 @@ class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -128,18 +129,18 @@ def __init__( self.group_quota_subscription_requests = GroupQuotaSubscriptionRequestsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.group_quota_limits = GroupQuotaLimitsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.group_quota_limits_request = GroupQuotaLimitsRequestOperations( self._client, self._config, self._serialize, self._deserialize ) - self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( + self.group_quota_limits = GroupQuotaLimitsOperations( self._client, self._config, self._serialize, self._deserialize ) self.group_quota_subscription_allocation_request = GroupQuotaSubscriptionAllocationRequestOperations( self._client, self._config, self._serialize, self._deserialize ) + self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.group_quota_usages = GroupQuotaUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -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..20971492f129 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.0b3" diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py index a538528c4864..2a9719088c93 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/_configuration.py @@ -28,13 +28,13 @@ class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attribu :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-15-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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..22c593fdc9ab 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 @@ -50,19 +51,19 @@ class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too :ivar group_quota_subscription_requests: GroupQuotaSubscriptionRequestsOperations operations :vartype group_quota_subscription_requests: azure.mgmt.quota.aio.operations.GroupQuotaSubscriptionRequestsOperations - :ivar group_quota_limits: GroupQuotaLimitsOperations operations - :vartype group_quota_limits: azure.mgmt.quota.aio.operations.GroupQuotaLimitsOperations :ivar group_quota_limits_request: GroupQuotaLimitsRequestOperations operations :vartype group_quota_limits_request: azure.mgmt.quota.aio.operations.GroupQuotaLimitsRequestOperations - :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations - operations - :vartype group_quota_subscription_allocation: - azure.mgmt.quota.aio.operations.GroupQuotaSubscriptionAllocationOperations + :ivar group_quota_limits: GroupQuotaLimitsOperations operations + :vartype group_quota_limits: azure.mgmt.quota.aio.operations.GroupQuotaLimitsOperations :ivar group_quota_subscription_allocation_request: GroupQuotaSubscriptionAllocationRequestOperations operations :vartype group_quota_subscription_allocation_request: azure.mgmt.quota.aio.operations.GroupQuotaSubscriptionAllocationRequestOperations + :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations + operations + :vartype group_quota_subscription_allocation: + azure.mgmt.quota.aio.operations.GroupQuotaSubscriptionAllocationOperations :ivar group_quota_usages: GroupQuotaUsagesOperations operations :vartype group_quota_usages: azure.mgmt.quota.aio.operations.GroupQuotaUsagesOperations :ivar group_quota_location_settings: GroupQuotaLocationSettingsOperations operations @@ -82,7 +83,7 @@ class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -128,18 +129,18 @@ def __init__( self.group_quota_subscription_requests = GroupQuotaSubscriptionRequestsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.group_quota_limits = GroupQuotaLimitsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.group_quota_limits_request = GroupQuotaLimitsRequestOperations( self._client, self._config, self._serialize, self._deserialize ) - self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( + self.group_quota_limits = GroupQuotaLimitsOperations( self._client, self._config, self._serialize, self._deserialize ) self.group_quota_subscription_allocation_request = GroupQuotaSubscriptionAllocationRequestOperations( self._client, self._config, self._serialize, self._deserialize ) + self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.group_quota_usages = GroupQuotaUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -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/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/__init__.py index 4bec73e40834..2a3c8e5dcf83 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/__init__.py @@ -9,10 +9,10 @@ from ._group_quotas_operations import GroupQuotasOperations from ._group_quota_subscriptions_operations import GroupQuotaSubscriptionsOperations from ._group_quota_subscription_requests_operations import GroupQuotaSubscriptionRequestsOperations -from ._group_quota_limits_operations import GroupQuotaLimitsOperations from ._group_quota_limits_request_operations import GroupQuotaLimitsRequestOperations -from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations +from ._group_quota_limits_operations import GroupQuotaLimitsOperations from ._group_quota_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations +from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations from ._group_quota_usages_operations import GroupQuotaUsagesOperations from ._group_quota_location_settings_operations import GroupQuotaLocationSettingsOperations from ._usages_operations import UsagesOperations @@ -28,10 +28,10 @@ "GroupQuotasOperations", "GroupQuotaSubscriptionsOperations", "GroupQuotaSubscriptionRequestsOperations", - "GroupQuotaLimitsOperations", "GroupQuotaLimitsRequestOperations", - "GroupQuotaSubscriptionAllocationOperations", + "GroupQuotaLimitsOperations", "GroupQuotaSubscriptionAllocationRequestOperations", + "GroupQuotaSubscriptionAllocationOperations", "GroupQuotaUsagesOperations", "GroupQuotaLocationSettingsOperations", "UsagesOperations", 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..a03094d1f638 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,10 +6,9 @@ # 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 urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,17 +18,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.tracing.decorator import distributed_trace +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._group_quota_limits_operations import build_get_request, build_list_request +from ...operations._group_quota_limits_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]] @@ -54,20 +54,14 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - resource_name: str, - filter: str, - **kwargs: Any - ) -> _models.GroupQuotaLimit: - """Gets the GroupQuotaLimits for the specific resource. - - Gets the GroupQuotaLimits for the specific resource for a specific resource based on the - resourceProviders, resourceName and $filter passed. - The $filter=location eq {location} is required to location specific resources groupQuota. + async def list( + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any + ) -> _models.GroupQuotaLimitList: + """Gets the GroupQuotaLimits for the specified resource provider and location for resource names + passed in $filter=resourceName eq {SKU}. + + Gets the GroupQuotaLimits for the specified resource provider and location for resource names + passed in $filter=resourceName eq {SKU}. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -77,24 +71,13 @@ async def get( :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: GroupQuotaLimit or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.GroupQuotaLimit + :param location: The name of the Azure region. Required. + :type location: str + :return: GroupQuotaLimitList or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.GroupQuotaLimitList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,19 +89,17 @@ async def get( _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[_models.GroupQuotaLimit] = kwargs.pop("cls", None) + cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - _request = build_get_request( + _request = build_list_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, - filter=filter, + location=location, api_version=api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -133,115 +114,9 @@ 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("GroupQuotaLimitList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any - ) -> AsyncIterable["_models.GroupQuotaLimit"]: - """Gets the GroupQuotaLimits for all the resources for the specified location in $filter=location - eq {location}. - - Gets the GroupQuotaLimits for the all resource for a specific resourceProvider and $filter - passed. - The $filter=location eq {location} is required to location specific resources groupQuota. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either GroupQuotaLimit or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.GroupQuotaLimit] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _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[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GroupQuotaLimitList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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..eadbb1820b50 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,14 +32,16 @@ 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, build_list_request, 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]] @@ -61,276 +65,16 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _create_or_update_initial( - self, - 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 = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(group_quota_request, (IOBase, bytes)): - _content = group_quota_request - else: - if group_quota_request is not None: - _json = self._serialize.body(group_quota_request, "SubmittedResourceRequestStatus") - else: - _json = None - - _request = build_create_or_update_request( - 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, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - 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]: - 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: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - 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", - **kwargs: Any - ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - 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", - **kwargs: Any - ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - 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]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.LROResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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[_models.SubmittedResourceRequestStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - 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._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, - group_quota_request=group_quota_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.SubmittedResourceRequestStatus].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SubmittedResourceRequestStatus]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - async def _update_initial( self, 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, + location: str, + group_quota_request: Optional[Union[_models.GroupQuotaLimitList, 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 +87,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 @@ -352,7 +96,7 @@ async def _update_initial( _content = group_quota_request else: if group_quota_request is not None: - _json = self._serialize.body(group_quota_request, "SubmittedResourceRequestStatus") + _json = self._serialize.body(group_quota_request, "GroupQuotaLimitList") else: _json = None @@ -360,7 +104,7 @@ 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, + location=location, api_version=api_version, content_type=content_type, json=_json, @@ -368,10 +112,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 +123,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 +139,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,16 +152,16 @@ 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, + location: str, + group_quota_request: Optional[_models.GroupQuotaLimitList] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: + ) -> AsyncLROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -429,18 +175,17 @@ 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 location: The name of the Azure region. Required. + :type location: 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 + :type group_quota_request: ~azure.mgmt.quota.models.GroupQuotaLimitList :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 - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :return: An instance of AsyncLROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -450,16 +195,16 @@ async def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, + location: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: + ) -> AsyncLROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -473,18 +218,17 @@ 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 location: The name of the Azure region. Required. + :type location: 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 - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :return: An instance of AsyncLROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -494,14 +238,14 @@ 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, + location: str, + group_quota_request: Optional[Union[_models.GroupQuotaLimitList, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.SubmittedResourceRequestStatus]: + ) -> AsyncLROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -515,16 +259,15 @@ 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 location: The name of the Azure region. Required. + :type location: 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 - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + resourceProvider/location/resources. Is either a GroupQuotaLimitList type or a IO[bytes] type. + Default value is None. + :type group_quota_request: ~azure.mgmt.quota.models.GroupQuotaLimitList or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -532,7 +275,7 @@ async def begin_update( 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[_models.SubmittedResourceRequestStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -541,7 +284,7 @@ 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, + location=location, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -550,10 +293,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("GroupQuotaLimitList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -567,13 +311,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.SubmittedResourceRequestStatus].from_continuation_token( + return AsyncLROPoller[_models.GroupQuotaLimitList].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.SubmittedResourceRequestStatus]( + return AsyncLROPoller[_models.GroupQuotaLimitList]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -596,7 +340,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 +362,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -633,7 +376,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 +422,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 +442,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 +457,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..8aa65031f7ca 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,10 +6,9 @@ # 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 urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,17 +18,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.tracing.decorator import distributed_trace +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request -from ...operations._group_quota_subscription_allocation_operations import build_get_request, build_list_request +from ...operations._group_quota_subscription_allocation_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]] @@ -53,146 +53,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, filter: str, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionQuotaAllocations"]: - """Gets all the quota allocated to a subscription for the specific Resource Provider, Location. - - Gets all the quota allocated to a subscription for the specific Resource Provider, Location. - This will include the GroupQuota and total quota allocated to the subscription. Only the Group - quota allocated to the subscription can be allocated back to the MG Group Quota. Use the - $filter parameter to filter out the specific resource based on the ResourceProvider/Location. - $filter is a required parameter. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :param filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either SubscriptionQuotaAllocations or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.SubscriptionQuotaAllocations] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _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[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionQuotaAllocationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def get( - self, management_group_id: str, group_quota_name: str, resource_name: str, filter: str, **kwargs: Any - ) -> _models.SubscriptionQuotaAllocations: - """Gets Quota allocated to a subscription for the specific Resource Provider, Location, - ResourceName. + async def list( + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any + ) -> _models.SubscriptionQuotaAllocationsList: + """Gets all the quota allocated to a subscription for the specified resource provider and location + for resource names passed in $filter=resourceName eq {SKU}. - Gets Quota allocated to a subscription for the specific Resource Provider, Location, - ResourceName. This will include the GroupQuota and total quota allocated to the subscription. - Only the Group quota allocated to the subscription can be allocated back to the MG Group Quota. + Gets all the quota allocated to a subscription for the specified resource provider and location + for resource names passed in $filter=resourceName eq {SKU}. This will include the GroupQuota + and total quota allocated to the subscription. Only the Group quota allocated to the + subscription can be allocated back to the MG Group Quota. :param management_group_id: Management Group Id. Required. :type management_group_id: str :param group_quota_name: The GroupQuota name. The name should be unique for the provided context tenantId/MgId. Required. :type group_quota_name: str - :param resource_name: Resource name. Required. - :type resource_name: str - :param filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: SubscriptionQuotaAllocations or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocations + :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 location: The name of the Azure region. Required. + :type location: str + :return: SubscriptionQuotaAllocationsList or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,19 +91,18 @@ async def get( _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[_models.SubscriptionQuotaAllocations] = kwargs.pop("cls", None) + cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) - _request = build_get_request( + _request = build_list_request( management_group_id=management_group_id, group_quota_name=group_quota_name, - resource_name=resource_name, + resource_provider_name=resource_provider_name, + location=location, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -231,7 +117,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("SubscriptionQuotaAllocationsList", 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..4b5574763d2e 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,14 +32,16 @@ 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, build_list_request, 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]] @@ -61,187 +65,16 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, management_group_id: str, group_quota_name: str, allocation_id: str, **kwargs: Any - ) -> _models.QuotaAllocationRequestStatus: - """Get the status of the quota allocation request for the subscriptionId. - - Get the quota allocation request status for the subscriptionId by allocationId. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :param allocation_id: Request Id. Required. - :type allocation_id: str - :return: QuotaAllocationRequestStatus or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - - _request = build_get_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - allocation_id=allocation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - 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]: - 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 = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any - ) -> AsyncIterable["_models.QuotaAllocationRequestStatus"]: - """Get all the quotaAllocationRequests for a resourceProvider/location. - - Get all the quotaAllocationRequests for a resourceProvider/location. The filter paramter for - location is required. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either QuotaAllocationRequestStatus or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _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[_models.QuotaAllocationRequestStatusList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatusList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_or_update_initial( + async def _update_initial( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + location: str, + allocate_quota_request: Union[_models.SubscriptionQuotaAllocationsList, 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 +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.QuotaAllocationRequestStatus, _models.LROResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -262,13 +95,13 @@ async def _create_or_update_initial( if isinstance(allocate_quota_request, (IOBase, bytes)): _content = allocate_quota_request else: - _json = self._serialize.body(allocate_quota_request, "QuotaAllocationRequestStatus") + _json = self._serialize.body(allocate_quota_request, "SubscriptionQuotaAllocationsList") - _request = build_create_or_update_request( + _request = build_update_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -277,33 +110,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 @@ -311,26 +145,26 @@ async def _create_or_update_initial( return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: _models.QuotaAllocationRequestStatus, + location: str, + allocate_quota_request: _models.SubscriptionQuotaAllocationsList, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: + ) -> AsyncLROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -340,42 +174,41 @@ 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 location: The name of the Azure region. Required. + :type location: str :param allocate_quota_request: Quota requests payload. Required. - :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus + :type allocate_quota_request: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList :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 SubscriptionQuotaAllocationsList 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.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, + location: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: + ) -> AsyncLROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -385,40 +218,39 @@ 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 location: The name of the Azure region. Required. + :type location: 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 SubscriptionQuotaAllocationsList 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.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( + async def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + location: str, + allocate_quota_request: Union[_models.SubscriptionQuotaAllocationsList, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: + ) -> AsyncLROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -428,17 +260,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 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 + :param location: The name of the Azure region. Required. + :type location: str + :param allocate_quota_request: Quota requests payload. Is either a + SubscriptionQuotaAllocationsList type or a IO[bytes] type. Required. + :type allocate_quota_request: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList 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 SubscriptionQuotaAllocationsList 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.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -446,16 +277,16 @@ async def begin_create_or_update( 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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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._create_or_update_initial( + raw_result = await self._update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + location=location, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -464,10 +295,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("SubscriptionQuotaAllocationsList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -481,26 +313,44 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.QuotaAllocationRequestStatus].from_continuation_token( + return AsyncLROPoller[_models.SubscriptionQuotaAllocationsList].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.QuotaAllocationRequestStatus]( + return AsyncLROPoller[_models.SubscriptionQuotaAllocationsList]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _update_initial( + @distributed_trace_async + async def get( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + allocation_id: str, **kwargs: Any - ) -> Optional[_models.QuotaAllocationRequestStatus]: - error_map = { + ) -> _models.QuotaAllocationRequestStatus: + """Get the status of the quota allocation request for the subscriptionId. + + Get the quota allocation request status for the subscriptionId by allocationId. + + :param management_group_id: Management Group Id. Required. + :type management_group_id: str + :param group_quota_name: The GroupQuota name. The name should be unique for the provided + context tenantId/MgId. Required. + :type group_quota_name: str + :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 allocation_id: Request Id. Required. + :type allocation_id: str + :return: QuotaAllocationRequestStatus or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,35 +358,22 @@ async def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) 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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(allocate_quota_request, (IOBase, bytes)): - _content = allocate_quota_request - else: - _json = self._serialize.body(allocate_quota_request, "QuotaAllocationRequestStatus") + cls: ClsType[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - _request = build_update_request( + _request = build_get_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + allocation_id=allocation_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -546,49 +383,26 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.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")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_update( - self, - 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", - **kwargs: Any - ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + @distributed_trace + def list( + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.QuotaAllocationRequestStatus"]: + """Get all the quotaAllocationRequests for a resourceProvider/location. - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. + Get all the quotaAllocationRequests for a resourceProvider/location. The filter paramter for + location is required. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -598,150 +412,90 @@ 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. - Default value is "application/json". - :paramtype content_type: str - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ + :param filter: .. list-table:: + :header-rows: 1 - @overload - async def begin_update( - self, - 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", - **kwargs: Any - ) -> AsyncLROPoller[_models.QuotaAllocationRequestStatus]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + * - Field + - Supported operators + * - - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 the - result of cls(response) + location eq {location} + Example: $filter=location eq eastus. Required. + :type filter: str + :return: An iterator like instance of either QuotaAllocationRequestStatus or the result of + cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace_async - async def begin_update( - self, - 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]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaAllocationRequestStatusList] = kwargs.pop("cls", None) - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - 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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - 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._update_initial( - 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, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + _request = build_list_request( + management_group_id=management_group_id, + group_quota_name=group_quota_name, + resource_provider_name=resource_provider_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("QuotaAllocationRequestStatusList", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.QuotaAllocationRequestStatus].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller[_models.QuotaAllocationRequestStatus]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_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/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py index e4f5c2ec6969..cd64e1124530 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/__init__.py @@ -23,6 +23,7 @@ from ._models_py3 import GroupQuotaDetailsName from ._models_py3 import GroupQuotaLimit from ._models_py3 import GroupQuotaLimitList +from ._models_py3 import GroupQuotaLimitListProperties from ._models_py3 import GroupQuotaList from ._models_py3 import GroupQuotaRequestBase from ._models_py3 import GroupQuotaRequestBaseProperties @@ -83,6 +84,7 @@ from ._models_py3 import SubscriptionQuotaAllocationRequestList from ._models_py3 import SubscriptionQuotaAllocations from ._models_py3 import SubscriptionQuotaAllocationsList +from ._models_py3 import SubscriptionQuotaAllocationsListProperties from ._models_py3 import SubscriptionQuotaAllocationsStatusList from ._models_py3 import SubscriptionQuotaDetails from ._models_py3 import SubscriptionQuotaDetailsName @@ -122,6 +124,7 @@ "GroupQuotaDetailsName", "GroupQuotaLimit", "GroupQuotaLimitList", + "GroupQuotaLimitListProperties", "GroupQuotaList", "GroupQuotaRequestBase", "GroupQuotaRequestBaseProperties", @@ -182,6 +185,7 @@ "SubscriptionQuotaAllocationRequestList", "SubscriptionQuotaAllocations", "SubscriptionQuotaAllocationsList", + "SubscriptionQuotaAllocationsListProperties", "SubscriptionQuotaAllocationsStatusList", "SubscriptionQuotaDetails", "SubscriptionQuotaDetailsName", 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..e6c9ec1cfbe3 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 @@ -456,18 +456,18 @@ class GroupQuotaDetails(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :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 limit: The current Group Quota Limit at the parentId level. :vartype limit: int :ivar comment: Any comment related to quota request. :vartype comment: str - :ivar name: Name of the resource provided by the resource provider. This property is already - included in the request URI, so it is a readonly property returned in the response. - :vartype name: ~azure.mgmt.quota.models.GroupQuotaDetailsName :ivar unit: The usages units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. :vartype unit: str + :ivar name: Name of the resource provided by the resource provider. This property is already + included in the request URI, so it is a readonly property returned in the response. + :vartype name: ~azure.mgmt.quota.models.GroupQuotaDetailsName :ivar available_limit: The available Group Quota Limit at the MG level. This Group quota can be allocated to subscription(s). :vartype available_limit: int @@ -476,39 +476,44 @@ class GroupQuotaDetails(_serialization.Model): """ _validation = { - "name": {"readonly": True}, "unit": {"readonly": True}, + "name": {"readonly": True}, "available_limit": {"readonly": True}, "allocated_to_subscriptions": {"readonly": True}, } _attribute_map = { - "region": {"key": "region", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, "limit": {"key": "limit", "type": "int"}, "comment": {"key": "comment", "type": "str"}, - "name": {"key": "name", "type": "GroupQuotaDetailsName"}, "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "GroupQuotaDetailsName"}, "available_limit": {"key": "availableLimit", "type": "int"}, "allocated_to_subscriptions": {"key": "allocatedToSubscriptions", "type": "AllocatedQuotaToSubscriptionList"}, } def __init__( - self, *, region: Optional[str] = None, limit: Optional[int] = None, comment: Optional[str] = None, **kwargs: Any + self, + *, + resource_name: Optional[str] = None, + limit: Optional[int] = None, + comment: Optional[str] = None, + **kwargs: Any ) -> None: """ - :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 limit: The current Group Quota Limit at the parentId level. :paramtype limit: int :keyword comment: Any comment related to quota request. :paramtype comment: str """ super().__init__(**kwargs) - self.region = region + self.resource_name = resource_name self.limit = limit self.comment = comment - self.name = None self.unit = None + self.name = None self.available_limit = None self.allocated_to_subscriptions = None @@ -542,6 +547,26 @@ def __init__(self, **kwargs: Any) -> None: self.localized_value = None +class GroupQuotaLimit(_serialization.Model): + """Group Quota limit. + + :ivar properties: Group Quota properties for the specified resource. + :vartype properties: ~azure.mgmt.quota.models.GroupQuotaDetails + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "GroupQuotaDetails"}, + } + + def __init__(self, *, properties: Optional["_models.GroupQuotaDetails"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Group Quota properties for the specified resource. + :paramtype properties: ~azure.mgmt.quota.models.GroupQuotaDetails + """ + super().__init__(**kwargs) + self.properties = properties + + class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. @@ -603,8 +628,8 @@ class ProxyResource(Resource): """ -class GroupQuotaLimit(ProxyResource): - """Group Quota limit. +class GroupQuotaLimitList(ProxyResource): + """List of Group Quota Limit details. Variables are only populated by the server, and will be ignored when sending a request. @@ -619,8 +644,8 @@ class GroupQuotaLimit(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.quota.models.SystemData - :ivar properties: Group Quota properties for the specified resource. - :vartype properties: ~azure.mgmt.quota.models.GroupQuotaDetails + :ivar properties: + :vartype properties: ~azure.mgmt.quota.models.GroupQuotaLimitListProperties """ _validation = { @@ -635,23 +660,26 @@ class GroupQuotaLimit(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "GroupQuotaDetails"}, + "properties": {"key": "properties", "type": "GroupQuotaLimitListProperties"}, } - def __init__(self, *, properties: Optional["_models.GroupQuotaDetails"] = None, **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.GroupQuotaLimitListProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Group Quota properties for the specified resource. - :paramtype properties: ~azure.mgmt.quota.models.GroupQuotaDetails + :keyword properties: + :paramtype properties: ~azure.mgmt.quota.models.GroupQuotaLimitListProperties """ super().__init__(**kwargs) self.properties = properties -class GroupQuotaLimitList(_serialization.Model): - """List of Group Quota Limit details. +class GroupQuotaLimitListProperties(_serialization.Model): + """GroupQuotaLimitListProperties. Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Request status. Known values are: "Accepted", "Created", "Invalid", + "Succeeded", "Failed", "InProgress", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState :ivar value: List of Group Quota Limit details. :vartype value: list[~azure.mgmt.quota.models.GroupQuotaLimit] :ivar next_link: The URL to use for getting the next set of results. @@ -659,10 +687,12 @@ class GroupQuotaLimitList(_serialization.Model): """ _validation = { + "provisioning_state": {"readonly": True}, "next_link": {"readonly": True}, } _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, "value": {"key": "value", "type": "[GroupQuotaLimit]"}, "next_link": {"key": "nextLink", "type": "str"}, } @@ -673,6 +703,7 @@ def __init__(self, *, value: Optional[List["_models.GroupQuotaLimit"]] = None, * :paramtype value: list[~azure.mgmt.quota.models.GroupQuotaLimit] """ super().__init__(**kwargs) + self.provisioning_state = None self.value = value self.next_link = None @@ -1980,7 +2011,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 +2168,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 +2364,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 @@ -2930,11 +2961,31 @@ def __init__(self, *, value: Optional[List["_models.QuotaAllocationRequestStatus self.next_link = None -class SubscriptionQuotaAllocations(ProxyResource): +class SubscriptionQuotaAllocations(_serialization.Model): """Quota allocated to a subscription for the specific Resource Provider, Location, ResourceName. This will include the GroupQuota and total quota allocated to the subscription. Only the Group quota allocated to the subscription can be allocated back to the MG Group Quota. + :ivar properties: Quota properties for the specified resource. + :vartype properties: ~azure.mgmt.quota.models.SubscriptionQuotaDetails + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "SubscriptionQuotaDetails"}, + } + + def __init__(self, *, properties: Optional["_models.SubscriptionQuotaDetails"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Quota properties for the specified resource. + :paramtype properties: ~azure.mgmt.quota.models.SubscriptionQuotaDetails + """ + super().__init__(**kwargs) + self.properties = properties + + +class SubscriptionQuotaAllocationsList(ProxyResource): + """Subscription quota list. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. @@ -2948,8 +2999,8 @@ class SubscriptionQuotaAllocations(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.quota.models.SystemData - :ivar properties: Quota properties for the specified resource. - :vartype properties: ~azure.mgmt.quota.models.SubscriptionQuotaDetails + :ivar properties: + :vartype properties: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsListProperties """ _validation = { @@ -2964,23 +3015,28 @@ class SubscriptionQuotaAllocations(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "SubscriptionQuotaDetails"}, + "properties": {"key": "properties", "type": "SubscriptionQuotaAllocationsListProperties"}, } - def __init__(self, *, properties: Optional["_models.SubscriptionQuotaDetails"] = None, **kwargs: Any) -> None: + def __init__( + self, *, properties: Optional["_models.SubscriptionQuotaAllocationsListProperties"] = None, **kwargs: Any + ) -> None: """ - :keyword properties: Quota properties for the specified resource. - :paramtype properties: ~azure.mgmt.quota.models.SubscriptionQuotaDetails + :keyword properties: + :paramtype properties: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsListProperties """ super().__init__(**kwargs) self.properties = properties -class SubscriptionQuotaAllocationsList(_serialization.Model): - """Subscription quota list. +class SubscriptionQuotaAllocationsListProperties(_serialization.Model): # pylint: disable=name-too-long + """SubscriptionQuotaAllocationsListProperties. Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Request status. Known values are: "Accepted", "Created", "Invalid", + "Succeeded", "Failed", "InProgress", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState :ivar value: Subscription quota list. :vartype value: list[~azure.mgmt.quota.models.SubscriptionQuotaAllocations] :ivar next_link: The URL to use for getting the next set of results. @@ -2988,10 +3044,12 @@ class SubscriptionQuotaAllocationsList(_serialization.Model): """ _validation = { + "provisioning_state": {"readonly": True}, "next_link": {"readonly": True}, } _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, "value": {"key": "value", "type": "[SubscriptionQuotaAllocations]"}, "next_link": {"key": "nextLink", "type": "str"}, } @@ -3002,6 +3060,7 @@ def __init__(self, *, value: Optional[List["_models.SubscriptionQuotaAllocations :paramtype value: list[~azure.mgmt.quota.models.SubscriptionQuotaAllocations] """ super().__init__(**kwargs) + self.provisioning_state = None self.value = value self.next_link = None @@ -3043,8 +3102,8 @@ class SubscriptionQuotaDetails(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :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 limit: The total quota limit for the subscription. :vartype limit: int :ivar shareable_quota: The shareable quota for the subscription. @@ -3060,21 +3119,21 @@ class SubscriptionQuotaDetails(_serialization.Model): } _attribute_map = { - "region": {"key": "region", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, "limit": {"key": "limit", "type": "int"}, "shareable_quota": {"key": "shareableQuota", "type": "int"}, "name": {"key": "name", "type": "SubscriptionQuotaDetailsName"}, } - def __init__(self, *, region: Optional[str] = None, limit: Optional[int] = None, **kwargs: Any) -> None: + def __init__(self, *, resource_name: Optional[str] = None, limit: Optional[int] = None, **kwargs: Any) -> None: """ - :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 limit: The total quota limit for the subscription. :paramtype limit: int """ super().__init__(**kwargs) - self.region = region + self.resource_name = resource_name self.limit = limit self.shareable_quota = None self.name = None @@ -3259,7 +3318,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/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/__init__.py index 4bec73e40834..2a3c8e5dcf83 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/__init__.py @@ -9,10 +9,10 @@ from ._group_quotas_operations import GroupQuotasOperations from ._group_quota_subscriptions_operations import GroupQuotaSubscriptionsOperations from ._group_quota_subscription_requests_operations import GroupQuotaSubscriptionRequestsOperations -from ._group_quota_limits_operations import GroupQuotaLimitsOperations from ._group_quota_limits_request_operations import GroupQuotaLimitsRequestOperations -from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations +from ._group_quota_limits_operations import GroupQuotaLimitsOperations from ._group_quota_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations +from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations from ._group_quota_usages_operations import GroupQuotaUsagesOperations from ._group_quota_location_settings_operations import GroupQuotaLocationSettingsOperations from ._usages_operations import UsagesOperations @@ -28,10 +28,10 @@ "GroupQuotasOperations", "GroupQuotaSubscriptionsOperations", "GroupQuotaSubscriptionRequestsOperations", - "GroupQuotaLimitsOperations", "GroupQuotaLimitsRequestOperations", - "GroupQuotaSubscriptionAllocationOperations", + "GroupQuotaLimitsOperations", "GroupQuotaSubscriptionAllocationRequestOperations", + "GroupQuotaSubscriptionAllocationOperations", "GroupQuotaUsagesOperations", "GroupQuotaLocationSettingsOperations", "UsagesOperations", 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..397b8240f31b 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,8 +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 urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +17,19 @@ ResourceNotModifiedError, map_error, ) -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]] @@ -36,69 +37,19 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - resource_name: str, - *, - filter: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaLimits/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url( - "management_group_id", management_group_id, "str", max_length=63, min_length=3 - ), - "groupQuotaName": _SERIALIZER.url( - "group_quota_name", group_quota_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" - ), - "resourceProviderName": _SERIALIZER.url( - "resource_provider_name", - resource_provider_name, - "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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaLimits", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaLimits/{location}", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -113,13 +64,13 @@ def build_list_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? _models.GroupQuotaLimit: - """Gets the GroupQuotaLimits for the specific resource. + def list( + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any + ) -> _models.GroupQuotaLimitList: + """Gets the GroupQuotaLimits for the specified resource provider and location for resource names + passed in $filter=resourceName eq {SKU}. - Gets the GroupQuotaLimits for the specific resource for a specific resource based on the - resourceProviders, resourceName and $filter passed. - The $filter=location eq {location} is required to location specific resources groupQuota. + Gets the GroupQuotaLimits for the specified resource provider and location for resource names + passed in $filter=resourceName eq {SKU}. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -170,24 +115,13 @@ def get( :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: GroupQuotaLimit or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.GroupQuotaLimit + :param location: The name of the Azure region. Required. + :type location: str + :return: GroupQuotaLimitList or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.GroupQuotaLimitList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,19 +133,17 @@ def get( _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[_models.GroupQuotaLimit] = kwargs.pop("cls", None) + cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - _request = build_get_request( + _request = build_list_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, - filter=filter, + location=location, api_version=api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,115 +158,9 @@ 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("GroupQuotaLimitList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any - ) -> Iterable["_models.GroupQuotaLimit"]: - """Gets the GroupQuotaLimits for all the resources for the specified location in $filter=location - eq {location}. - - Gets the GroupQuotaLimits for the all resource for a specific resourceProvider and $filter - passed. - The $filter=location eq {location} is required to location specific resources groupQuota. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either GroupQuotaLimit or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.GroupQuotaLimit] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _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[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("GroupQuotaLimitList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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..d4847544b1ae 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]] @@ -39,66 +44,20 @@ _SERIALIZER.client_side_validation = False -def build_create_or_update_request( - management_group_id: str, group_quota_name: str, resource_provider_name: str, resource_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/groupQuotaRequests/{resourceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url( - "management_group_id", management_group_id, "str", max_length=63, min_length=3 - ), - "groupQuotaName": _SERIALIZER.url( - "group_quota_name", group_quota_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" - ), - "resourceProviderName": _SERIALIZER.url( - "resource_provider_name", - resource_provider_name, - "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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # 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}/groupQuotaLimits/{location}", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -113,9 +72,7 @@ def build_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? Union[_models.SubmittedResourceRequestStatus, _models.LROResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(group_quota_request, (IOBase, bytes)): - _content = group_quota_request - else: - if group_quota_request is not None: - _json = self._serialize.body(group_quota_request, "SubmittedResourceRequestStatus") - else: - _json = None - - _request = build_create_or_update_request( - 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, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - 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]: - 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: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - 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", - **kwargs: Any - ) -> LROPoller[_models.SubmittedResourceRequestStatus]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :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: - """ - - @overload - def begin_create_or_update( - self, - 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", - **kwargs: Any - ) -> LROPoller[_models.SubmittedResourceRequestStatus]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :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: - """ - - @distributed_trace - def begin_create_or_update( - self, - 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]: - """Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. - - Put the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location and - resourceName ("name": {"value" : "resourceName") properties are specified in the request body. - Only 1 resource quota can be requested. - Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with - retry-after duration in seconds to check the intermediate status. This API provides the finals - status with the request details and status. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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) - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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[_models.SubmittedResourceRequestStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - 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._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, - group_quota_request=group_quota_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SubmittedResourceRequestStatus", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.SubmittedResourceRequestStatus].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SubmittedResourceRequestStatus]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - def _update_initial( self, 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, + location: str, + group_quota_request: Optional[Union[_models.GroupQuotaLimitList, 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 +205,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 @@ -514,7 +214,7 @@ def _update_initial( _content = group_quota_request else: if group_quota_request is not None: - _json = self._serialize.body(group_quota_request, "SubmittedResourceRequestStatus") + _json = self._serialize.body(group_quota_request, "GroupQuotaLimitList") else: _json = None @@ -522,7 +222,7 @@ 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, + location=location, api_version=api_version, content_type=content_type, json=_json, @@ -530,10 +230,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 +241,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 +257,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,16 +270,16 @@ 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, + location: str, + group_quota_request: Optional[_models.GroupQuotaLimitList] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SubmittedResourceRequestStatus]: + ) -> LROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -591,17 +293,17 @@ 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 location: The name of the Azure region. Required. + :type location: 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 + :type group_quota_request: ~azure.mgmt.quota.models.GroupQuotaLimitList :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 the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :return: An instance of LROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -611,16 +313,16 @@ def begin_update( management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, + location: str, group_quota_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.SubmittedResourceRequestStatus]: + ) -> LROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -634,17 +336,17 @@ 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 location: The name of the Azure region. Required. + :type location: 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 the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :return: An instance of LROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -654,14 +356,14 @@ 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, + location: str, + group_quota_request: Optional[Union[_models.GroupQuotaLimitList, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.SubmittedResourceRequestStatus]: + ) -> LROPoller[_models.GroupQuotaLimitList]: """Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. - Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. the location - and resourceName properties are specified in the request body. Only 1 resource quota can be + Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The + resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request. Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals @@ -675,15 +377,15 @@ 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 location: The name of the Azure region. Required. + :type location: 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 the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + resourceProvider/location/resources. Is either a GroupQuotaLimitList type or a IO[bytes] type. + Default value is None. + :type group_quota_request: ~azure.mgmt.quota.models.GroupQuotaLimitList or IO[bytes] + :return: An instance of LROPoller that returns either GroupQuotaLimitList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotaLimitList] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -691,7 +393,7 @@ def begin_update( 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[_models.SubmittedResourceRequestStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.GroupQuotaLimitList] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -700,7 +402,7 @@ 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, + location=location, group_quota_request=group_quota_request, api_version=api_version, content_type=content_type, @@ -709,10 +411,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("GroupQuotaLimitList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -726,13 +429,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.SubmittedResourceRequestStatus].from_continuation_token( + return LROPoller[_models.GroupQuotaLimitList].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.SubmittedResourceRequestStatus]( + return LROPoller[_models.GroupQuotaLimitList]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -755,7 +458,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 +480,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -792,7 +494,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 +539,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 +559,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 +574,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..c0a2dba317cb 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]] @@ -45,7 +50,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -89,7 +94,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -133,7 +138,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -174,7 +179,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..d7bc8fdb60b4 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,8 +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 urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +17,19 @@ ResourceNotModifiedError, map_error, ) -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]] @@ -37,60 +38,23 @@ def build_list_request( - management_group_id: str, group_quota_name: str, subscription_id: str, *, filter: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url( - "management_group_id", management_group_id, "str", max_length=63, min_length=3 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "groupQuotaName": _SERIALIZER.url( - "group_quota_name", group_quota_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", min_length=12) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( management_group_id: str, group_quota_name: str, - resource_name: str, + resource_provider_name: str, + location: str, subscription_id: str, - *, - filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocations/{resourceName}", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/quotaAllocations/{location}", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -100,16 +64,19 @@ def build_get_request( "groupQuotaName": _SERIALIZER.url( "group_quota_name", group_quota_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" ), - "resourceName": _SERIALIZER.url( - "resource_name", resource_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" + "resourceProviderName": _SERIALIZER.url( + "resource_provider_name", + resource_provider_name, + "str", + pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? Iterable["_models.SubscriptionQuotaAllocations"]: - """Gets all the quota allocated to a subscription for the specific Resource Provider, Location. - - Gets all the quota allocated to a subscription for the specific Resource Provider, Location. - This will include the GroupQuota and total quota allocated to the subscription. Only the Group - quota allocated to the subscription can be allocated back to the MG Group Quota. Use the - $filter parameter to filter out the specific resource based on the ResourceProvider/Location. - $filter is a required parameter. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :param filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either SubscriptionQuotaAllocations or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.SubscriptionQuotaAllocations] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any + ) -> _models.SubscriptionQuotaAllocationsList: + """Gets all the quota allocated to a subscription for the specified resource provider and location + for resource names passed in $filter=resourceName eq {SKU}. - 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 = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionQuotaAllocationsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, management_group_id: str, group_quota_name: str, resource_name: str, filter: str, **kwargs: Any - ) -> _models.SubscriptionQuotaAllocations: - """Gets Quota allocated to a subscription for the specific Resource Provider, Location, - ResourceName. - - Gets Quota allocated to a subscription for the specific Resource Provider, Location, - ResourceName. This will include the GroupQuota and total quota allocated to the subscription. - Only the Group quota allocated to the subscription can be allocated back to the MG Group Quota. + Gets all the quota allocated to a subscription for the specified resource provider and location + for resource names passed in $filter=resourceName eq {SKU}. This will include the GroupQuota + and total quota allocated to the subscription. Only the Group quota allocated to the + subscription can be allocated back to the MG Group Quota. :param management_group_id: Management Group Id. Required. :type management_group_id: str :param group_quota_name: The GroupQuota name. The name should be unique for the provided context tenantId/MgId. Required. :type group_quota_name: str - :param resource_name: Resource name. Required. - :type resource_name: str - :param filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: SubscriptionQuotaAllocations or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocations + :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 location: The name of the Azure region. Required. + :type location: str + :return: SubscriptionQuotaAllocationsList or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,19 +141,18 @@ def get( _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[_models.SubscriptionQuotaAllocations] = kwargs.pop("cls", None) + cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) - _request = build_get_request( + _request = build_list_request( management_group_id=management_group_id, group_quota_name=group_quota_name, - resource_name=resource_name, + resource_provider_name=resource_provider_name, + location=location, subscription_id=self._config.subscription_id, - filter=filter, api_version=api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -313,7 +167,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("SubscriptionQuotaAllocationsList", 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..fdaf81fee0ca 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]] @@ -39,61 +44,25 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - management_group_id: str, group_quota_name: str, allocation_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/quotaAllocationRequests/{allocationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url( - "management_group_id", management_group_id, "str", max_length=63, min_length=3 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "groupQuotaName": _SERIALIZER.url( - "group_quota_name", group_quota_name, "str", max_length=63, min_length=3, pattern=r"^[a-z][a-z0-9]*$" - ), - "allocationId": _SERIALIZER.url("allocation_id", allocation_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( +def build_update_request( management_group_id: str, group_quota_name: str, resource_provider_name: str, + location: str, subscription_id: str, - *, - filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/quotaAllocationRequests", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/subscriptions/{subscriptionId}/providers/Microsoft.Quota/groupQuotas/{groupQuotaName}/resourceProviders/{resourceProviderName}/quotaAllocations/{location}", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -109,39 +78,40 @@ def build_list_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # 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}/quotaAllocationRequests/{allocationId}", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -157,9 +127,7 @@ 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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # 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}/quotaAllocationRequests", ) # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url( @@ -209,22 +175,18 @@ def build_update_request( "str", pattern=r"^((?!-)[a-zA-Z0-9-]{1,63}(? _models.QuotaAllocationRequestStatus: - """Get the status of the quota allocation request for the subscriptionId. - - Get the quota allocation request status for the subscriptionId by allocationId. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :param allocation_id: Request Id. Required. - :type allocation_id: str - :return: QuotaAllocationRequestStatus or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - - _request = build_get_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - allocation_id=allocation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - 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]: - 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 = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any - ) -> Iterable["_models.QuotaAllocationRequestStatus"]: - """Get all the quotaAllocationRequests for a resourceProvider/location. - - Get all the quotaAllocationRequests for a resourceProvider/location. The filter paramter for - location is required. - - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 filter: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - * - - - - location eq {location} - Example: $filter=location eq eastus. Required. - :type filter: str - :return: An iterator like instance of either QuotaAllocationRequestStatus or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _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[_models.QuotaAllocationRequestStatusList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _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 - - def extract_data(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatusList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - 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]: - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _create_or_update_initial( + def _update_initial( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + location: str, + allocate_quota_request: Union[_models.SubscriptionQuotaAllocationsList, IO[bytes]], **kwargs: Any - ) -> Union[_models.QuotaAllocationRequestStatus, _models.LROResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +230,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 @@ -446,13 +238,13 @@ def _create_or_update_initial( if isinstance(allocate_quota_request, (IOBase, bytes)): _content = allocate_quota_request else: - _json = self._serialize.body(allocate_quota_request, "QuotaAllocationRequestStatus") + _json = self._serialize.body(allocate_quota_request, "SubscriptionQuotaAllocationsList") - _request = build_create_or_update_request( + _request = build_update_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -461,33 +253,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 @@ -495,26 +288,26 @@ def _create_or_update_initial( return deserialized # type: ignore @overload - def begin_create_or_update( + def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: _models.QuotaAllocationRequestStatus, + location: str, + allocate_quota_request: _models.SubscriptionQuotaAllocationsList, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.QuotaAllocationRequestStatus]: + ) -> LROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -524,41 +317,41 @@ 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 location: The name of the Azure region. Required. + :type location: str :param allocate_quota_request: Quota requests payload. Required. - :type allocate_quota_request: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus + :type allocate_quota_request: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList :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 SubscriptionQuotaAllocationsList or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, + location: str, allocate_quota_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.QuotaAllocationRequestStatus]: + ) -> LROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -568,39 +361,39 @@ 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 location: The name of the Azure region. Required. + :type location: 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 SubscriptionQuotaAllocationsList or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_update( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + location: str, + allocate_quota_request: Union[_models.SubscriptionQuotaAllocationsList, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.QuotaAllocationRequestStatus]: + ) -> LROPoller[_models.SubscriptionQuotaAllocationsList]: """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern to check the status using Async polling as standards defined at - - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#asynchronous-operations. + Asynchronous pattern with 202 response and status polling API. Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to subscriptions or reduce the quota allocated to subscription to give back the unused quota ( quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. + the GroupQuota. User can collect unused quotas from multiple subscriptions within the + groupQuota and assign the groupQuota to the subscription, where it's needed. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -610,16 +403,16 @@ 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 + :param location: The name of the Azure region. Required. + :type location: str + :param allocate_quota_request: Quota requests payload. Is either a + SubscriptionQuotaAllocationsList type or a IO[bytes] type. Required. + :type allocate_quota_request: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList 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 SubscriptionQuotaAllocationsList or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.SubscriptionQuotaAllocationsList] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -627,16 +420,16 @@ def begin_create_or_update( 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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.SubscriptionQuotaAllocationsList] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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._create_or_update_initial( + raw_result = self._update_initial( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + location=location, allocate_quota_request=allocate_quota_request, api_version=api_version, content_type=content_type, @@ -645,10 +438,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("SubscriptionQuotaAllocationsList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -662,26 +456,44 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.QuotaAllocationRequestStatus].from_continuation_token( + return LROPoller[_models.SubscriptionQuotaAllocationsList].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.QuotaAllocationRequestStatus]( + return LROPoller[_models.SubscriptionQuotaAllocationsList]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _update_initial( + @distributed_trace + def get( self, management_group_id: str, group_quota_name: str, resource_provider_name: str, - resource_name: str, - allocate_quota_request: Union[_models.QuotaAllocationRequestStatus, IO[bytes]], + allocation_id: str, **kwargs: Any - ) -> Optional[_models.QuotaAllocationRequestStatus]: - error_map = { + ) -> _models.QuotaAllocationRequestStatus: + """Get the status of the quota allocation request for the subscriptionId. + + Get the quota allocation request status for the subscriptionId by allocationId. + + :param management_group_id: Management Group Id. Required. + :type management_group_id: str + :param group_quota_name: The GroupQuota name. The name should be unique for the provided + context tenantId/MgId. Required. + :type group_quota_name: str + :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 allocation_id: Request Id. Required. + :type allocation_id: str + :return: QuotaAllocationRequestStatus or the result of cls(response) + :rtype: ~azure.mgmt.quota.models.QuotaAllocationRequestStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,35 +501,22 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) 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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(allocate_quota_request, (IOBase, bytes)): - _content = allocate_quota_request - else: - _json = self._serialize.body(allocate_quota_request, "QuotaAllocationRequestStatus") + cls: ClsType[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - _request = build_update_request( + _request = build_get_request( management_group_id=management_group_id, group_quota_name=group_quota_name, resource_provider_name=resource_provider_name, - resource_name=resource_name, + allocation_id=allocation_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -727,49 +526,26 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.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")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) + deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_update( - self, - 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", - **kwargs: Any - ) -> LROPoller[_models.QuotaAllocationRequestStatus]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + @distributed_trace + def list( + self, management_group_id: str, group_quota_name: str, resource_provider_name: str, filter: str, **kwargs: Any + ) -> Iterable["_models.QuotaAllocationRequestStatus"]: + """Get all the quotaAllocationRequests for a resourceProvider/location. - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. + Get all the quotaAllocationRequests for a resourceProvider/location. The filter paramter for + location is required. :param management_group_id: Management Group Id. Required. :type management_group_id: str @@ -779,147 +555,89 @@ 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. - Default value is "application/json". - :paramtype content_type: str - :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: - """ + :param filter: .. list-table:: + :header-rows: 1 - @overload - def begin_update( - self, - 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", - **kwargs: Any - ) -> LROPoller[_models.QuotaAllocationRequestStatus]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + * - Field + - Supported operators + * - - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] + location eq {location} + Example: $filter=location eq eastus. Required. + :type filter: str + :return: An iterator like instance of either QuotaAllocationRequestStatus or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.QuotaAllocationRequestStatus] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace - def begin_update( - self, - 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]: - """Request to assign quota from group quota to a specific Subscription. This request will use - Asynchronous pattern with 202 response and status polling API. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.QuotaAllocationRequestStatusList] = kwargs.pop("cls", None) - Request to assign quota from group quota to a specific Subscription. The assign GroupQuota to - subscriptions or reduce the quota allocated to subscription to give back the unused quota ( - quota >= usages) to the groupQuota. So, this API can be used to assign Quota to subscriptions - and assign back unused quota to group quota, which can be assigned to another subscriptions in - the GroupQuota. User can collect unused quotas from multiple subscriptions within the - groupQuota and assign the groupQuota to the subscription, where it's needed. + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param management_group_id: Management Group Id. Required. - :type management_group_id: str - :param group_quota_name: The GroupQuota name. The name should be unique for the provided - context tenantId/MgId. Required. - :type group_quota_name: str - :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 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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - 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[_models.QuotaAllocationRequestStatus] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - 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._update_initial( - 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, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + _request = build_list_request( + management_group_id=management_group_id, + group_quota_name=group_quota_name, + resource_provider_name=resource_provider_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("QuotaAllocationRequestStatus", pipeline_response) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("QuotaAllocationRequestStatusList", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.QuotaAllocationRequestStatus].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[_models.QuotaAllocationRequestStatus]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_requests_operations.py index 14fb393141c7..d35bcffa38a3 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]] @@ -40,7 +43,7 @@ def build_list_request(management_group_id: str, group_quota_name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..ce7cc3308b59 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]] @@ -44,7 +49,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +84,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +119,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +154,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +187,7 @@ def build_list_request(management_group_id: str, group_quota_name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..1d434ed8f40b 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]] @@ -42,7 +45,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..1fbdd24c7221 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]] @@ -43,7 +48,7 @@ def build_create_or_update_request(management_group_id: str, group_quota_name: s _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -78,7 +83,7 @@ def build_update_request(management_group_id: str, group_quota_name: str, **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -113,7 +118,7 @@ def build_get_request(management_group_id: str, group_quota_name: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +150,7 @@ def build_delete_request(management_group_id: str, group_quota_name: str, **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +182,7 @@ def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..38d9c8c9369f 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]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..dd130e590c1c 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]] @@ -43,7 +48,7 @@ def build_get_request(resource_name: str, scope: str, **kwargs: Any) -> HttpRequ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,7 @@ def build_create_or_update_request(resource_name: str, scope: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -96,7 +101,7 @@ def build_update_request(resource_name: str, scope: str, **kwargs: Any) -> HttpR _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -124,7 +129,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..bad5b3127c9b 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]] @@ -40,7 +43,7 @@ def build_get_request(id: str, scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..b4ef49abc45f 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]] @@ -40,7 +43,7 @@ def build_get_request(resource_name: str, scope: str, **kwargs: Any) -> HttpRequ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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/get_compute_one_sku_quota_limit.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_quota_limit.py index c0cd5e4f40dd..46f5d7fd78c3 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_quota_limit.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_quota_limit.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getComputeOneSkuQuotaLimit.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_usages.py index 50d977fdace6..5fb4218b1b16 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_one_sku_usages.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getComputeOneSkuUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_quota_limits.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_quota_limits.py index 9769dd829332..268903e056a6 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_quota_limits.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_quota_limits.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeQuotaLimits.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getComputeQuotaLimits.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_usages.py index 39b2dd500fbd..1921710db6c4 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_compute_usages.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getComputeUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_quota_limits.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_quota_limits.py index 270e278748d6..7680e842e69e 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_quota_limits.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_quota_limits.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getMachineLearningServicesQuotaLimits.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getMachineLearningServicesQuotaLimits.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_usages.py index d4654c449965..7bbc8e606a18 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_machine_learning_services_usages.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getMachineLearningServicesUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getMachineLearningServicesUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_quota_limit.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_quota_limit.py index e8c2263f0498..3f3c6b8beef0 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_quota_limit.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_quota_limit.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getNetworkOneSkuQuotaLimit.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_usages.py index bcd92ea649c0..4e95ddb612e2 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_one_sku_usages.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getNetworkOneSkuUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_quota_limits.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_quota_limits.py index f838c6cd0153..62fb2219f7d8 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_quota_limits.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_quota_limits.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkQuotaLimits.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getNetworkQuotaLimits.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_usages.py index b64e3a265cd4..d367d690119f 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_network_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_network_usages.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getNetworkUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_operations.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_operations.py index 4fc48c3f9531..5a7c260b1aaa 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_operations.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_operations.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GetOperations.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GetOperations.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_by_id.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_by_id.py index b80909055b84..f5dda6b1abc9 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_by_id.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_by_id.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getQuotaRequestStatusById.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_failed.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_failed.py index 96246e072fa6..e09e79ae2836 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_failed.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_failed.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusFailed.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getQuotaRequestStatusFailed.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_in_progress.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_in_progress.py index 90d084706698..773e7a2230ed 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_in_progress.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_request_status_in_progress.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getQuotaRequestStatusInProgress.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_requests_history.py b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_requests_history.py index f667b546be1b..247436d105ab 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_requests_history.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/get_quota_requests_history.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestsHistory.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/getQuotaRequestsHistory.json if __name__ == "__main__": main() 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/list_group_quota_limits_compute.py similarity index 82% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/put_group_quota_limits_requests_compute.py rename to sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/list_group_quota_limits_compute.py index ff3fc743b593..97b0981b32c1 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/list_group_quota_limits_compute.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python put_group_quota_limits_requests_compute.py + 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, @@ -30,15 +30,15 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.group_quota_limits_request.begin_create_or_update( + response = client.group_quota_limits.list( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", - ).result() + location="westus", + ) print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimitsRequests/PutGroupQuotaLimitsRequests-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-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..cba1f2701c8e --- /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/2024-10-15-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..cb88ca10f966 --- /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/2024-10-15-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..bcdea8179b69 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,11 +34,11 @@ def main(): management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", - resource_name="standardav2family", + location="westus", ).result() print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimitsRequests/PatchGroupQuotaLimitsRequests-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotaLimitsRequests/PatchGroupQuotaLimitsRequests-Compute.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_usages/get_group_quota_usages.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_usages/get_group_quota_usages.py index bc1933186d0f..9d6fd7a5f788 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_usages/get_group_quota_usages.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quota_usages/get_group_quota_usages.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaUsages/GetGroupQuotaUsages.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotaUsages/GetGroupQuotaUsages.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/delete_group_quotas.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/delete_group_quotas.py index fdb271fe342c..bd0faa7618d5 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/delete_group_quotas.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/delete_group_quotas.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/DeleteGroupQuotas.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotas/DeleteGroupQuotas.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas.py index 764ef79e7fb2..b6397a56cc0a 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotas/GetGroupQuotas.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas_list.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas_list.py index 8d8500e87981..12c705929c39 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas_list.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/get_group_quotas_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotasList.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotas/GetGroupQuotasList.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/patch_group_quotas.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/patch_group_quotas.py index 81dc1db6c2e8..9e15ac65cf59 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/patch_group_quotas.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/patch_group_quotas.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/PatchGroupQuotas.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotas/PatchGroupQuotas.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/put_group_quotas.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/put_group_quotas.py index 9fcc055f977e..f5d34e05d490 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/put_group_quotas.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas/put_group_quotas.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/PutGroupQuotas.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotas/PutGroupQuotas.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/get_group_quota_enforcement.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/get_group_quota_enforcement.py index f5a831eb29ee..ff1caeb2efe7 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/get_group_quota_enforcement.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/get_group_quota_enforcement.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/list_group_quota_enforcement.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/list_group_quota_enforcement.py index 370bafd60457..32ee4407f1bf 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/list_group_quota_enforcement.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/list_group_quota_enforcement.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/ListGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasEnforcement/ListGroupQuotaEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/patch_group_quota_enforcement.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/patch_group_quota_enforcement.py index f39d48ae8cb1..951effd114df 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/patch_group_quota_enforcement.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/patch_group_quota_enforcement.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PatchGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasEnforcement/PatchGroupQuotaEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement.py index 2038a8b2dfa9..b0c4aaf20deb 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PutGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasEnforcement/PutGroupQuotaEnforcement.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement_failed.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement_failed.py index 799470d1607b..6f58e98b53b9 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement_failed.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement_failed.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PutGroupQuotaEnforcementFailed.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasEnforcement/PutGroupQuotaEnforcementFailed.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/delete_group_quota_subscriptions.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/delete_group_quota_subscriptions.py index 54d4895f0ab7..4bdc0ff79954 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/delete_group_quota_subscriptions.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/delete_group_quota_subscriptions.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/DeleteGroupQuotaSubscriptions.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasSubscriptions/DeleteGroupQuotaSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/get_group_quota_subscriptions.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/get_group_quota_subscriptions.py index 59e2818751aa..2e1bf0f8737b 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/get_group_quota_subscriptions.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/get_group_quota_subscriptions.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/list_group_quota_subscriptions.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/list_group_quota_subscriptions.py index 2e1ced786c5d..947237d6897f 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/list_group_quota_subscriptions.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/list_group_quota_subscriptions.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/ListGroupQuotaSubscriptions.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasSubscriptions/ListGroupQuotaSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/patch_group_quotas_subscription.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/patch_group_quotas_subscription.py index 3d5e98344ea0..50390f777f52 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/patch_group_quotas_subscription.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/patch_group_quotas_subscription.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/PatchGroupQuotasSubscription.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasSubscriptions/PatchGroupQuotasSubscription.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/put_group_quotas_subscription.py b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/put_group_quotas_subscription.py index aab7cb1bd821..d3acf31865bf 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/put_group_quotas_subscription.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_subscriptions/put_group_quotas_subscription.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/PutGroupQuotasSubscription.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/GroupQuotasSubscriptions/PutGroupQuotasSubscription.json if __name__ == "__main__": main() 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..77dc1f320114 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 @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/patchComputeQuotaRequest.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/patchComputeQuotaRequest.json if __name__ == "__main__": main() 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..a8729f30de65 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 @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/patchNetworkOneSkuQuotaRequest.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/patchNetworkOneSkuQuotaRequest.json if __name__ == "__main__": main() 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..4244398f01b9 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 @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/putComputeOneSkuQuotaRequest.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/putComputeOneSkuQuotaRequest.json if __name__ == "__main__": main() 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..4d5b7ab4e746 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 @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/putMachineLearningServicesQuotaRequestLowPriority.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/putMachineLearningServicesQuotaRequestLowPriority.json if __name__ == "__main__": main() 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..c061c464c974 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 @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/putNetworkOneSkuQuotaRequest.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/putNetworkOneSkuQuotaRequest.json if __name__ == "__main__": main() 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..8add45cd12db 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 @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/putNetworkOneSkuQuotaRequestStandardSkuPublicIpAddresses.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/putNetworkOneSkuQuotaRequestStandardSkuPublicIpAddresses.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..afb3327ce475 --- /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", + resource_provider_name="Microsoft.Compute", + location="westus", + ) + print(response) + + +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-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..e3542269b741 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,12 +34,19 @@ 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"}}}}, + location="westus", + allocate_quota_request={ + "properties": { + "value": [ + {"properties": {"limit": 110, "resourceName": "standardddv4family"}}, + {"properties": {"limit": 110, "resourceName": "standardav2family"}}, + ] + } + }, ).result() print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PatchSubscriptionQuotaAllocationRequest-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/SubscriptionQuotaAllocationRequests/PatchSubscriptionQuotaAllocationRequest-Compute.json if __name__ == "__main__": main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_get_compute.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_get_compute.py index dca9a0ff7dd9..431fd0869b50 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_get_compute.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_get_compute.py @@ -33,11 +33,12 @@ def main(): response = client.group_quota_subscription_allocation_request.get( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", + resource_provider_name="Microsoft.Compute", allocation_id="AE000000-0000-0000-0000-00000000000A", ) print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_Get-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_Get-Compute.json if __name__ == "__main__": main() 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/subscription_quota_allocation_requests_list_compute.py similarity index 76% rename from sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py rename to sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py index 403032ea4440..e31e0a44e75a 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/subscription_quota_allocation_requests_list_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 @@ -17,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python put_subscription_quota_allocation_request_compute.py + 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, @@ -32,16 +30,16 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.group_quota_subscription_allocation_request.begin_create_or_update( + 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", - resource_name="standardav2family", - allocate_quota_request={"properties": {"requestedResource": {"properties": {"limit": 10, "region": "westus"}}}}, - ).result() - print(response) + 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/PutSubscriptionQuotaAllocationRequest-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-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..cc96f0773880 --- /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/2024-10-15-preview/examples/SubscriptionRequests/SubscriptionRequests_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_list.py b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_list.py index 9c220faf58ba..acbecfbafcf9 100644 --- a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_list.py +++ b/sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_List.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2024-10-15-preview/examples/SubscriptionRequests/SubscriptionRequests_List.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..58f1b61f66e5 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_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 TestQuotaMgmtGroupQuotaLimitsOperations(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_limits.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2024-10-15-preview", + ) + + # 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..7689c45de82a --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_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 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_list(self, resource_group): + response = await self.client.group_quota_limits.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2024-10-15-preview", + ) + + # 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..9a649fd46a42 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations.py @@ -0,0 +1,60 @@ +# 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_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", + location="str", + api_version="2024-10-15-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="2024-10-15-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="2024-10-15-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..1c7639825f88 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_limits_request_operations_async.py @@ -0,0 +1,63 @@ +# 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_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", + location="str", + api_version="2024-10-15-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="2024-10-15-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="2024-10-15-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..39219ab6c09c --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..f60825474b00 --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..e05fb8b3866a --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_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 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", + resource_provider_name="str", + location="str", + api_version="2024-10-15-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..1b6b3ea419bf --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_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 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 = await self.client.group_quota_subscription_allocation.list( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + location="str", + api_version="2024-10-15-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..bb8b4405cbbc --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations.py @@ -0,0 +1,88 @@ +# 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_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", + location="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "nextLink": "str", + "provisioningState": "str", + "value": [ + { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "resourceName": "str", + "shareableQuota": 0, + } + } + ], + }, + "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="2024-10-15-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_subscription_allocation_request.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocation_id="str", + api_version="2024-10-15-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="2024-10-15-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_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..fed7b5e48b54 --- /dev/null +++ b/sdk/quota/azure-mgmt-quota/generated_tests/test_quota_mgmt_group_quota_subscription_allocation_request_operations_async.py @@ -0,0 +1,91 @@ +# 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_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", + location="str", + allocate_quota_request={ + "id": "str", + "name": "str", + "properties": { + "nextLink": "str", + "provisioningState": "str", + "value": [ + { + "properties": { + "limit": 0, + "name": {"localizedValue": "str", "value": "str"}, + "resourceName": "str", + "shareableQuota": 0, + } + } + ], + }, + "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="2024-10-15-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_subscription_allocation_request.get( + management_group_id="str", + group_quota_name="str", + resource_provider_name="str", + allocation_id="str", + api_version="2024-10-15-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="2024-10-15-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_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..53f168d6a18b --- /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="2024-10-15-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="2024-10-15-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..e96dd50f7430 --- /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="2024-10-15-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="2024-10-15-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..c89e48cb6f09 --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..26aa3047b5ba --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..5ee48a025668 --- /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="2024-10-15-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..b71f831e0f95 --- /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="2024-10-15-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..4eeee0dfcf21 --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..60f288c814f8 --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..3da509be1c32 --- /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="2024-10-15-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..0a5883c68d7f --- /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="2024-10-15-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..8c3b97988326 --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..30b7040cc16b --- /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="2024-10-15-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="2024-10-15-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="2024-10-15-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="2024-10-15-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..c3ce178a2280 --- /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="2024-10-15-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="2024-10-15-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..ef1d1f1cc480 --- /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="2024-10-15-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="2024-10-15-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..53405e697609 --- /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="2024-10-15-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="2024-10-15-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..5fe22393272d --- /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="2024-10-15-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="2024-10-15-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", ],