diff --git a/sdk/quota/azure-mgmt-quota/_meta.json b/sdk/quota/azure-mgmt-quota/_meta.json index 74f21603f73a..a3de04e47784 100644 --- a/sdk/quota/azure-mgmt-quota/_meta.json +++ b/sdk/quota/azure-mgmt-quota/_meta.json @@ -1,11 +1,11 @@ { - "commit": "665e7c3b6f26b148b3c05e55602621bc293cc0a4", + "commit": "b61faf671b791e2dfa1c37b80f79ad6f9f5bb53e", "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.26.4", "@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.26.4 --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/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py index c2236cbe06e3..ca2fd1eaa0f5 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._quota_mgmt_client import QuotaMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._quota_mgmt_client import QuotaMgmtClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "QuotaMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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..f85dc016e6bc 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for QuotaMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -28,13 +27,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 - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-12-12". 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-12-12") 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..dc2c46829906 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 @@ -20,12 +21,10 @@ from .operations import ( GroupQuotaLimitsOperations, GroupQuotaLimitsRequestOperations, - GroupQuotaLocationSettingsOperations, GroupQuotaSubscriptionAllocationOperations, GroupQuotaSubscriptionAllocationRequestOperations, GroupQuotaSubscriptionRequestsOperations, GroupQuotaSubscriptionsOperations, - GroupQuotaUsagesOperations, GroupQuotasOperations, QuotaOperationOperations, QuotaOperations, @@ -34,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class QuotaMgmtClient: # pylint: disable=too-many-instance-attributes """Microsoft Azure Quota Resource Provider. This Swagger is for Azure Group Quota using GroupQuota Entity. @@ -50,24 +48,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_usages: GroupQuotaUsagesOperations operations - :vartype group_quota_usages: azure.mgmt.quota.operations.GroupQuotaUsagesOperations - :ivar group_quota_location_settings: GroupQuotaLocationSettingsOperations operations - :vartype group_quota_location_settings: - azure.mgmt.quota.operations.GroupQuotaLocationSettingsOperations + :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations + operations + :vartype group_quota_subscription_allocation: + azure.mgmt.quota.operations.GroupQuotaSubscriptionAllocationOperations :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.quota.operations.UsagesOperations :ivar quota: QuotaOperations operations @@ -82,8 +75,8 @@ 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 - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-12-12". 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 Retry-After header is present. @@ -128,22 +121,16 @@ 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_usages = GroupQuotaUsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.group_quota_location_settings = GroupQuotaLocationSettingsOperations( + self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( self._client, self._config, self._serialize, self._deserialize ) self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -178,7 +165,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..ce17d1798ce7 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,7 +25,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +52,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -91,6 +90,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +113,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -144,6 +145,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 @@ -153,6 +156,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -182,15 +190,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -204,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -233,24 +256,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -298,13 +330,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -324,7 +366,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -344,7 +390,9 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -378,12 +426,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -393,7 +444,7 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -406,6 +457,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @@ -424,9 +476,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -446,21 +500,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -499,11 +557,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer(object): # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -538,7 +598,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -558,13 +618,16 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -590,12 +653,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -631,7 +696,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -662,17 +728,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -701,7 +767,7 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError("Unable to build a model: " + str(err)) from err @@ -710,9 +776,11 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -726,21 +794,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -757,19 +824,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -778,21 +846,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -803,7 +870,7 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -819,11 +886,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -839,23 +905,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -869,8 +938,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -880,15 +948,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -943,9 +1009,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -969,7 +1034,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -977,6 +1042,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1001,7 +1067,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1032,56 +1098,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1089,11 +1160,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1103,30 +1175,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1139,12 +1213,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1170,13 +1245,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1184,11 +1260,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1209,7 +1285,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1230,17 +1308,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1277,7 +1367,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1329,22 +1419,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1361,9 +1450,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1401,11 +1490,12 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1414,12 +1504,13 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1438,13 +1529,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if 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 + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1474,9 +1565,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1503,6 +1593,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1514,7 +1606,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1529,10 +1621,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1550,10 +1644,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1577,14 +1673,21 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + ] + const = [ + k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: @@ -1594,7 +1697,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1603,15 +1706,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1729,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1645,14 +1753,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1669,6 +1777,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1679,11 +1788,12 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1718,11 +1828,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1730,6 +1839,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1741,24 +1851,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1766,6 +1875,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1779,8 +1889,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1792,6 +1901,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1802,9 +1912,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1820,6 +1930,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1832,6 +1943,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1847,8 +1959,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1863,6 +1976,7 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1875,6 +1989,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -1885,14 +2000,14 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -1908,6 +2023,7 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -1922,6 +2038,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1937,14 +2054,14 @@ def deserialize_rfc(attr): except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1974,8 +2091,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1983,6 +2099,7 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ @@ -1994,5 +2111,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj 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/__init__.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py index 6197d6e20563..f26294359742 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._quota_mgmt_client import QuotaMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._quota_mgmt_client import QuotaMgmtClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "QuotaMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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..fb65807a0edd 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 @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class QuotaMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for QuotaMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -28,13 +27,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 - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-12-12". 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-12-12") 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..ce53e576ff74 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 @@ -20,12 +21,10 @@ from .operations import ( GroupQuotaLimitsOperations, GroupQuotaLimitsRequestOperations, - GroupQuotaLocationSettingsOperations, GroupQuotaSubscriptionAllocationOperations, GroupQuotaSubscriptionAllocationRequestOperations, GroupQuotaSubscriptionRequestsOperations, GroupQuotaSubscriptionsOperations, - GroupQuotaUsagesOperations, GroupQuotasOperations, QuotaOperationOperations, QuotaOperations, @@ -34,11 +33,10 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class QuotaMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes +class QuotaMgmtClient: # pylint: disable=too-many-instance-attributes """Microsoft Azure Quota Resource Provider. This Swagger is for Azure Group Quota using GroupQuota Entity. @@ -50,24 +48,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_usages: GroupQuotaUsagesOperations operations - :vartype group_quota_usages: azure.mgmt.quota.aio.operations.GroupQuotaUsagesOperations - :ivar group_quota_location_settings: GroupQuotaLocationSettingsOperations operations - :vartype group_quota_location_settings: - azure.mgmt.quota.aio.operations.GroupQuotaLocationSettingsOperations + :ivar group_quota_subscription_allocation: GroupQuotaSubscriptionAllocationOperations + operations + :vartype group_quota_subscription_allocation: + azure.mgmt.quota.aio.operations.GroupQuotaSubscriptionAllocationOperations :ivar usages: UsagesOperations operations :vartype usages: azure.mgmt.quota.aio.operations.UsagesOperations :ivar quota: QuotaOperations operations @@ -82,8 +75,8 @@ 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 - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-12-12". 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 Retry-After header is present. @@ -128,22 +121,16 @@ 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_usages = GroupQuotaUsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.group_quota_location_settings = GroupQuotaLocationSettingsOperations( + self.group_quota_subscription_allocation = GroupQuotaSubscriptionAllocationOperations( self._client, self._config, self._serialize, self._deserialize ) self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -180,7 +167,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..7baec1eac569 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 @@ -5,39 +5,41 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -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_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations -from ._group_quota_usages_operations import GroupQuotaUsagesOperations -from ._group_quota_location_settings_operations import GroupQuotaLocationSettingsOperations -from ._usages_operations import UsagesOperations -from ._quota_operations import QuotaOperations -from ._quota_request_status_operations import QuotaRequestStatusOperations -from ._quota_operation_operations import QuotaOperationOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._group_quotas_operations import GroupQuotasOperations # type: ignore +from ._group_quota_subscriptions_operations import GroupQuotaSubscriptionsOperations # type: ignore +from ._group_quota_subscription_requests_operations import GroupQuotaSubscriptionRequestsOperations # type: ignore +from ._group_quota_limits_request_operations import GroupQuotaLimitsRequestOperations # type: ignore +from ._group_quota_limits_operations import GroupQuotaLimitsOperations # type: ignore +from ._group_quota_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations # type: ignore +from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations # type: ignore +from ._usages_operations import UsagesOperations # type: ignore +from ._quota_operations import QuotaOperations # type: ignore +from ._quota_request_status_operations import QuotaRequestStatusOperations # type: ignore +from ._quota_operation_operations import QuotaOperationOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "GroupQuotasOperations", "GroupQuotaSubscriptionsOperations", "GroupQuotaSubscriptionRequestsOperations", - "GroupQuotaLimitsOperations", "GroupQuotaLimitsRequestOperations", - "GroupQuotaSubscriptionAllocationOperations", + "GroupQuotaLimitsOperations", "GroupQuotaSubscriptionAllocationRequestOperations", - "GroupQuotaUsagesOperations", - "GroupQuotaLocationSettingsOperations", + "GroupQuotaSubscriptionAllocationOperations", "UsagesOperations", "QuotaOperations", "QuotaRequestStatusOperations", "QuotaOperationOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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..3532ca4bfeff 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,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, TypeVar -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,17 +17,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,20 +53,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 +70,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,19 +88,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 +113,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..ffeb592d9c3b 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,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 @@ -30,14 +31,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,276 +64,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,7 +86,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 +95,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 +103,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 +111,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 +122,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 +138,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 +151,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 +174,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 +194,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 +217,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 +237,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 +258,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 +274,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 +283,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 +292,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 +310,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 +339,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -618,7 +361,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -633,7 +375,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 +421,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,7 +441,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 +456,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 deleted file mode 100644 index 51c9f3cbdb4f..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_location_settings_operations.py +++ /dev/null @@ -1,785 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# 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 io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.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 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, - build_list_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GroupQuotaLocationSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.quota.aio.QuotaMgmtClient`'s - :attr:`group_quota_location_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_or_update_initial( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> Union[_models.GroupQuotasEnforcementResponse, _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.GroupQuotasEnforcementResponse, _models.LROResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(location_settings, (IOBase, bytes)): - _content = location_settings - else: - if location_settings is not None: - _json = self._serialize.body(location_settings, "GroupQuotasEnforcementResponse") - 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, - location=location, - 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("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")) - 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, - location: str, - location_settings: Optional[_models.GroupQuotasEnforcementResponse] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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 GroupQuotasEnforcementResponse or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] 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, - location: str, - location_settings: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: 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 GroupQuotasEnforcementResponse or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] 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, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Is either a GroupQuotasEnforcementResponse type or a IO[bytes] type. Default value is - None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GroupQuotasEnforcementResponse or An - instance of AsyncLROPoller that returns either LROResponse or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] 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.GroupQuotasEnforcementResponse] = 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, - location=location, - location_settings=location_settings, - 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("GroupQuotasEnforcementResponse", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.GroupQuotasEnforcementResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GroupQuotasEnforcementResponse]( - 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, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> Optional[_models.GroupQuotasEnforcementResponse]: - 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[Optional[_models.GroupQuotasEnforcementResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(location_settings, (IOBase, bytes)): - _content = location_settings - else: - if location_settings is not None: - _json = self._serialize.body(location_settings, "GroupQuotasEnforcementResponse") - else: - _json = None - - _request = build_update_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - location=location, - 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, 202]: - 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")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[_models.GroupQuotasEnforcementResponse] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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 GroupQuotasEnforcementResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: 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 GroupQuotasEnforcementResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Is either a GroupQuotasEnforcementResponse type or a IO[bytes] type. Default value is - None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GroupQuotasEnforcementResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :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.GroupQuotasEnforcementResponse] = 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, - location=location, - location_settings=location_settings, - 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("GroupQuotasEnforcementResponse", 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, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.GroupQuotasEnforcementResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GroupQuotasEnforcementResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any - ) -> _models.GroupQuotasEnforcementResponse: - """Gets the GroupQuotas enforcement settings for the resource provider/location. - - Gets the GroupQuotas enforcement settings for the ResourceProvider/location. The locations, - where GroupQuota enforcement is not enabled will return Not Found. - - :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 location: The name of the Azure region. Required. - :type location: str - :return: GroupQuotasEnforcementResponse or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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.GroupQuotasEnforcementResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - location=location, - 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("GroupQuotasEnforcementResponse", 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, **kwargs: Any - ) -> AsyncIterable["_models.GroupQuotasEnforcementResponse"]: - """Returns a list of the Azure regions settings, where the GroupQuotas enforcement is enabled. - - Returns only the list of the Azure regions settings, where the GroupQuotas enforcement is - enabled. The locations not included in GroupQuota Enforcement will not be listed, the regions - in failed status with listed as status Failed. - - :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 - :return: An iterator like instance of either GroupQuotasEnforcementResponse or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :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.GroupQuotasEnforcementListResponse] = 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, - 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("GroupQuotasEnforcementListResponse", 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_subscription_allocation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_subscription_allocation_operations.py index c985a4910a29..3ea33765adf6 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,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, TypeVar -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,17 +17,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,146 +52,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,19 +90,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 +116,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..eab120cfa967 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,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 @@ -30,14 +31,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,187 +64,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,7 +86,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 +94,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 +109,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 +144,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 +173,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 +217,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 +259,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 +276,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 +294,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 +312,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,35 +357,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 +382,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 +411,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 = { + 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..e3c221acaaba 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -19,17 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +81,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,7 +99,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 +114,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 +167,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,7 +189,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -204,7 +203,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..159a469356d1 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +5,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, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +16,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 +30,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 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,8 +67,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -76,7 +80,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 +90,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 +101,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 +117,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 +164,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 +194,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -201,7 +207,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 +217,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 +228,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 +244,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 +289,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 +317,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +332,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 +342,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 +353,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 +369,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 +403,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 +412,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 +455,7 @@ async def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionId :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,7 +477,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,7 +491,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 +523,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +541,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 +556,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 deleted file mode 100644 index 07665a95fc0e..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quota_usages_operations.py +++ /dev/null @@ -1,147 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.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 - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GroupQuotaUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.quota.aio.QuotaMgmtClient`'s - :attr:`group_quota_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUsages"]: - """Gets the GroupQuotas usages and limits(quota) for the resourceProvider/location. - - Gets the GroupQuotas usages and limits(quota). Location is required paramter. - - :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 location: The name of the Azure region. Required. - :type location: str - :return: An iterator like instance of either ResourceUsages or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.quota.models.ResourceUsages] - :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.ResourceUsageList] = 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, - location=location, - 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("ResourceUsageList", 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_quotas_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/aio/operations/_group_quotas_operations.py index b3e39f24093c..6925bacce3c5 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,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 @@ -30,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_quotas_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,8 +72,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,7 +86,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 +109,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 +120,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 +136,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 +270,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 +304,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +318,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 +341,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 +352,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 +368,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 +506,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 +550,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,7 +571,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 +585,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -599,7 +607,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 +616,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 +627,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 +643,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 +677,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 +686,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 +729,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -729,7 +746,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 +761,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..158809704a3e 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -19,16 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +70,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,7 +86,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 +101,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..327acb131fc2 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,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 @@ -30,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._quota_operations import ( build_create_or_update_request, build_get_request, @@ -38,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,6 +67,7 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace_async async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentQuotaLimitBase: + # pylint: disable=line-too-long """Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new quota limit that can be submitted with a PUT request. @@ -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 = { 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 = { 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 @@ -203,6 +209,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -224,8 +231,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 @@ -248,6 +255,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -269,8 +277,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] @@ -291,6 +299,7 @@ async def begin_create_or_update( create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -312,8 +321,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 +353,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 +388,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,7 +402,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 +422,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 +433,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 @@ -446,6 +458,7 @@ async def begin_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -466,8 +479,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 @@ -490,6 +503,7 @@ async def begin_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -510,8 +524,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] @@ -532,6 +546,7 @@ async def begin_update( create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -552,8 +567,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 +599,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 @@ -614,14 +630,15 @@ def get_long_running_output(pipeline_response): @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentQuotaLimitBase"]: + # pylint: disable=line-too-long """Get a list of current quota limits of all resources for the specified scope. The response from this GET operation can be leveraged to submit requests to update a quota. :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 +651,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,7 +668,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 +683,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..b9d7169a37f2 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -19,17 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace_async async def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestDetails: + # pylint: disable=line-too-long """Get the quota request details and status by quota request ID for the resources of the resource provider at a specific location. The quota request ID **id** is returned in the response of the PUT operation. @@ -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 = { 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 @@ -123,14 +125,15 @@ def list( skiptoken: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.QuotaRequestDetails"]: + # pylint: disable=line-too-long """For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the **oData** filter to select quota requests. :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 +164,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,7 +184,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 +199,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..dd52b0779414 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -19,17 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace_async async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentUsagesBase: + # pylint: disable=line-too-long """Get the current usage of a resource. :param resource_name: Resource name for a given resource provider. For example: @@ -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 = { 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 @@ -122,13 +124,14 @@ async def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.Cu @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.CurrentUsagesBase"]: + # pylint: disable=line-too-long """Get a list of current usage for all resources for the scope specified. :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 +143,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -157,7 +160,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 +175,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..76744306190b 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 @@ -5,111 +5,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AdditionalAttributes -from ._models_py3 import AdditionalAttributesPatch -from ._models_py3 import AllocatedQuotaToSubscriptionList -from ._models_py3 import AllocatedToSubscription -from ._models_py3 import BillingAccountId -from ._models_py3 import CommonResourceProperties -from ._models_py3 import CreateGenericQuotaRequestParameters -from ._models_py3 import CurrentQuotaLimitBase -from ._models_py3 import CurrentUsagesBase -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import ExceptionResponse -from ._models_py3 import GroupQuotaDetails -from ._models_py3 import GroupQuotaDetailsName -from ._models_py3 import GroupQuotaLimit -from ._models_py3 import GroupQuotaLimitList -from ._models_py3 import GroupQuotaList -from ._models_py3 import GroupQuotaRequestBase -from ._models_py3 import GroupQuotaRequestBaseProperties -from ._models_py3 import GroupQuotaRequestBasePropertiesName -from ._models_py3 import GroupQuotaSubscriptionId -from ._models_py3 import GroupQuotaSubscriptionIdList -from ._models_py3 import GroupQuotaSubscriptionIdProperties -from ._models_py3 import GroupQuotaSubscriptionRequestStatus -from ._models_py3 import GroupQuotaSubscriptionRequestStatusList -from ._models_py3 import GroupQuotaSubscriptionRequestStatusProperties -from ._models_py3 import GroupQuotaUsagesBase -from ._models_py3 import GroupQuotaUsagesBaseName -from ._models_py3 import GroupQuotasEnforcementListResponse -from ._models_py3 import GroupQuotasEnforcementResponse -from ._models_py3 import GroupQuotasEnforcementResponseProperties -from ._models_py3 import GroupQuotasEntity -from ._models_py3 import GroupQuotasEntityBase -from ._models_py3 import GroupQuotasEntityBasePatch -from ._models_py3 import GroupQuotasEntityPatch -from ._models_py3 import GroupingId -from ._models_py3 import LROResponse -from ._models_py3 import LROResponseProperties -from ._models_py3 import LimitJsonObject -from ._models_py3 import LimitObject -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationList -from ._models_py3 import OperationResponse -from ._models_py3 import ProxyResource -from ._models_py3 import QuotaAllocationRequestBase -from ._models_py3 import QuotaAllocationRequestBaseProperties -from ._models_py3 import QuotaAllocationRequestBasePropertiesName -from ._models_py3 import QuotaAllocationRequestStatus -from ._models_py3 import QuotaAllocationRequestStatusList -from ._models_py3 import QuotaAllocationRequestStatusProperties -from ._models_py3 import QuotaLimits -from ._models_py3 import QuotaLimitsResponse -from ._models_py3 import QuotaProperties -from ._models_py3 import QuotaRequestDetails -from ._models_py3 import QuotaRequestDetailsList -from ._models_py3 import QuotaRequestOneResourceProperties -from ._models_py3 import QuotaRequestOneResourceSubmitResponse -from ._models_py3 import QuotaRequestProperties -from ._models_py3 import QuotaRequestStatusDetails -from ._models_py3 import QuotaRequestSubmitResponse -from ._models_py3 import QuotaRequestSubmitResponse202 -from ._models_py3 import Resource -from ._models_py3 import ResourceBaseRequest -from ._models_py3 import ResourceName -from ._models_py3 import ResourceUsageList -from ._models_py3 import ResourceUsages -from ._models_py3 import ServiceError -from ._models_py3 import ServiceErrorDetail -from ._models_py3 import SubRequest -from ._models_py3 import SubmittedResourceRequestStatus -from ._models_py3 import SubmittedResourceRequestStatusList -from ._models_py3 import SubmittedResourceRequestStatusProperties -from ._models_py3 import SubscriptionGroupQuotaAssignment -from ._models_py3 import SubscriptionQuotaAllocationRequestList -from ._models_py3 import SubscriptionQuotaAllocations -from ._models_py3 import SubscriptionQuotaAllocationsList -from ._models_py3 import SubscriptionQuotaAllocationsStatusList -from ._models_py3 import SubscriptionQuotaDetails -from ._models_py3 import SubscriptionQuotaDetailsName -from ._models_py3 import SystemData -from ._models_py3 import UsagesLimits -from ._models_py3 import UsagesObject -from ._models_py3 import UsagesProperties +from typing import TYPE_CHECKING -from ._quota_mgmt_client_enums import CreatedByType -from ._quota_mgmt_client_enums import EnforcementState -from ._quota_mgmt_client_enums import EnvironmentType -from ._quota_mgmt_client_enums import GroupingIdType -from ._quota_mgmt_client_enums import LimitType -from ._quota_mgmt_client_enums import QuotaLimitTypes -from ._quota_mgmt_client_enums import QuotaRequestState -from ._quota_mgmt_client_enums import RequestState -from ._quota_mgmt_client_enums import UsagesTypes +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AllocatedQuotaToSubscriptionList, + AllocatedToSubscription, + CommonResourceProperties, + CreateGenericQuotaRequestParameters, + CurrentQuotaLimitBase, + CurrentUsagesBase, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + ExceptionResponse, + GroupQuotaDetails, + GroupQuotaDetailsName, + GroupQuotaLimit, + GroupQuotaLimitList, + GroupQuotaLimitListProperties, + GroupQuotaLimitProperties, + GroupQuotaList, + GroupQuotaRequestBase, + GroupQuotaRequestBaseProperties, + GroupQuotaRequestBasePropertiesName, + GroupQuotaSubscriptionId, + GroupQuotaSubscriptionIdList, + GroupQuotaSubscriptionIdProperties, + GroupQuotaSubscriptionRequestStatus, + GroupQuotaSubscriptionRequestStatusList, + GroupQuotaSubscriptionRequestStatusProperties, + GroupQuotaUsagesBase, + GroupQuotaUsagesBaseName, + GroupQuotasEntity, + GroupQuotasEntityBase, + GroupQuotasEntityBasePatch, + GroupQuotasEntityPatch, + GroupQuotasEntityPatchProperties, + GroupQuotasEntityProperties, + LROResponse, + LROResponseProperties, + LimitJsonObject, + LimitObject, + OperationDisplay, + OperationList, + OperationResponse, + ProxyResource, + QuotaAllocationRequestBase, + QuotaAllocationRequestBaseProperties, + QuotaAllocationRequestBasePropertiesName, + QuotaAllocationRequestStatus, + QuotaAllocationRequestStatusList, + QuotaAllocationRequestStatusProperties, + QuotaLimits, + QuotaLimitsResponse, + QuotaProperties, + QuotaRequestDetails, + QuotaRequestDetailsList, + QuotaRequestOneResourceProperties, + QuotaRequestOneResourceSubmitResponse, + QuotaRequestProperties, + QuotaRequestStatusDetails, + QuotaRequestSubmitResponse, + QuotaRequestSubmitResponse202, + Resource, + ResourceBaseRequest, + ResourceName, + ResourceUsageList, + ResourceUsages, + ServiceError, + ServiceErrorDetail, + SubRequest, + SubmittedResourceRequestStatus, + SubmittedResourceRequestStatusList, + SubmittedResourceRequestStatusProperties, + SubscriptionGroupQuotaAssignment, + SubscriptionQuotaAllocationRequestList, + SubscriptionQuotaAllocations, + SubscriptionQuotaAllocationsList, + SubscriptionQuotaAllocationsListProperties, + SubscriptionQuotaAllocationsProperties, + SubscriptionQuotaAllocationsStatusList, + SubscriptionQuotaDetails, + SubscriptionQuotaDetailsName, + SystemData, + UsagesLimits, + UsagesObject, + UsagesProperties, +) + +from ._quota_mgmt_client_enums import ( # type: ignore + CreatedByType, + LimitType, + QuotaLimitTypes, + QuotaRequestState, + RequestState, + UsagesTypes, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AdditionalAttributes", - "AdditionalAttributesPatch", "AllocatedQuotaToSubscriptionList", "AllocatedToSubscription", - "BillingAccountId", "CommonResourceProperties", "CreateGenericQuotaRequestParameters", "CurrentQuotaLimitBase", @@ -122,6 +126,8 @@ "GroupQuotaDetailsName", "GroupQuotaLimit", "GroupQuotaLimitList", + "GroupQuotaLimitListProperties", + "GroupQuotaLimitProperties", "GroupQuotaList", "GroupQuotaRequestBase", "GroupQuotaRequestBaseProperties", @@ -134,14 +140,12 @@ "GroupQuotaSubscriptionRequestStatusProperties", "GroupQuotaUsagesBase", "GroupQuotaUsagesBaseName", - "GroupQuotasEnforcementListResponse", - "GroupQuotasEnforcementResponse", - "GroupQuotasEnforcementResponseProperties", "GroupQuotasEntity", "GroupQuotasEntityBase", "GroupQuotasEntityBasePatch", "GroupQuotasEntityPatch", - "GroupingId", + "GroupQuotasEntityPatchProperties", + "GroupQuotasEntityProperties", "LROResponse", "LROResponseProperties", "LimitJsonObject", @@ -182,6 +186,8 @@ "SubscriptionQuotaAllocationRequestList", "SubscriptionQuotaAllocations", "SubscriptionQuotaAllocationsList", + "SubscriptionQuotaAllocationsListProperties", + "SubscriptionQuotaAllocationsProperties", "SubscriptionQuotaAllocationsStatusList", "SubscriptionQuotaDetails", "SubscriptionQuotaDetailsName", @@ -190,14 +196,11 @@ "UsagesObject", "UsagesProperties", "CreatedByType", - "EnforcementState", - "EnvironmentType", - "GroupingIdType", "LimitType", "QuotaLimitTypes", "QuotaRequestState", "RequestState", "UsagesTypes", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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..e8a6f41044c5 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 @@ -1,5 +1,5 @@ -# coding=utf-8 # pylint: disable=too-many-lines +# 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. @@ -16,90 +16,13 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AdditionalAttributes(_serialization.Model): - """Additional attribute or filter to allow subscriptions meeting the requirements to be part of - the GroupQuota. - - All required parameters must be populated in order to send to server. - - :ivar group_id: The grouping Id for the group quota. It can be Billing Id or ServiceTreeId if - applicable. Required. - :vartype group_id: ~azure.mgmt.quota.models.GroupingId - :ivar environment: Environment name. Known values are: "NonProduction" and "Production". - :vartype environment: str or ~azure.mgmt.quota.models.EnvironmentType - """ - - _validation = { - "group_id": {"required": True}, - } - - _attribute_map = { - "group_id": {"key": "groupId", "type": "GroupingId"}, - "environment": {"key": "environment", "type": "str"}, - } - - def __init__( - self, - *, - group_id: "_models.GroupingId", - environment: Optional[Union[str, "_models.EnvironmentType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The grouping Id for the group quota. It can be Billing Id or ServiceTreeId - if applicable. Required. - :paramtype group_id: ~azure.mgmt.quota.models.GroupingId - :keyword environment: Environment name. Known values are: "NonProduction" and "Production". - :paramtype environment: str or ~azure.mgmt.quota.models.EnvironmentType - """ - super().__init__(**kwargs) - self.group_id = group_id - self.environment = environment - - -class AdditionalAttributesPatch(_serialization.Model): - """Additional attribute or filter to allow subscriptions meeting the requirements to be part of - the GroupQuota. - - :ivar group_id: The grouping Id for the group quota. It can be Billing Id or ServiceTreeId if - applicable. - :vartype group_id: ~azure.mgmt.quota.models.GroupingId - :ivar environment: Environment name. Known values are: "NonProduction" and "Production". - :vartype environment: str or ~azure.mgmt.quota.models.EnvironmentType - """ - - _attribute_map = { - "group_id": {"key": "groupId", "type": "GroupingId"}, - "environment": {"key": "environment", "type": "str"}, - } - - def __init__( - self, - *, - group_id: Optional["_models.GroupingId"] = None, - environment: Optional[Union[str, "_models.EnvironmentType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_id: The grouping Id for the group quota. It can be Billing Id or ServiceTreeId - if applicable. - :paramtype group_id: ~azure.mgmt.quota.models.GroupingId - :keyword environment: Environment name. Known values are: "NonProduction" and "Production". - :paramtype environment: str or ~azure.mgmt.quota.models.EnvironmentType - """ - super().__init__(**kwargs) - self.group_id = group_id - self.environment = environment - - class AllocatedQuotaToSubscriptionList(_serialization.Model): """Quota allocated to subscriptions. @@ -150,26 +73,6 @@ def __init__( self.quota_allocated = quota_allocated -class BillingAccountId(_serialization.Model): - """A Billing Account Id. - - :ivar id: - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - class CommonResourceProperties(_serialization.Model): """Resource properties. @@ -417,57 +320,23 @@ def __init__(self, *, error: Optional["_models.ServiceError"] = None, **kwargs: self.error = error -class GroupingId(_serialization.Model): - """The grouping Id for the group quota. It can be Billing Id or ServiceTreeId if applicable. - - :ivar grouping_id_type: GroupingId type. It is a required property. More types of groupIds can - be supported in future. Known values are: "ServiceTreeId" and "BillingId". - :vartype grouping_id_type: str or ~azure.mgmt.quota.models.GroupingIdType - :ivar value: GroupId value based on the groupingType selected - Billing Id or ServiceTreeId. - :vartype value: str - """ - - _attribute_map = { - "grouping_id_type": {"key": "groupingIdType", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, - *, - grouping_id_type: Optional[Union[str, "_models.GroupingIdType"]] = None, - value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword grouping_id_type: GroupingId type. It is a required property. More types of groupIds - can be supported in future. Known values are: "ServiceTreeId" and "BillingId". - :paramtype grouping_id_type: str or ~azure.mgmt.quota.models.GroupingIdType - :keyword value: GroupId value based on the groupingType selected - Billing Id or ServiceTreeId. - :paramtype value: str - """ - super().__init__(**kwargs) - self.grouping_id_type = grouping_id_type - self.value = value - - class GroupQuotaDetails(_serialization.Model): """Group Quota details. 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 +345,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 +416,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.GroupQuotaLimitProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "GroupQuotaLimitProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GroupQuotaLimitProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Group Quota properties for the specified resource. + :paramtype properties: ~azure.mgmt.quota.models.GroupQuotaLimitProperties + """ + 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 +497,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 +513,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 +529,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 +556,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,10 +572,36 @@ 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 +class GroupQuotaLimitProperties(GroupQuotaDetails): + """Group Quota properties for the specified resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 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 + :ivar allocated_to_subscriptions: Quota allocated to subscriptions. + :vartype allocated_to_subscriptions: ~azure.mgmt.quota.models.AllocatedQuotaToSubscriptionList + """ + + class GroupQuotaList(_serialization.Model): """List of Group Quotas at MG level. @@ -812,124 +737,6 @@ def __init__(self, **kwargs: Any) -> None: self.localized_value = None -class GroupQuotasEnforcementListResponse(_serialization.Model): - """List of Azure regions, where the group quotas is enabled for enforcement. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Azure Regions. - :vartype value: list[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GroupQuotasEnforcementResponse]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.GroupQuotasEnforcementResponse"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of Azure Regions. - :paramtype value: list[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class GroupQuotasEnforcementResponse(ProxyResource): - """The GroupQuota Enforcement status for a Azure Location/Region. - - 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. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.quota.models.SystemData - :ivar properties: - :vartype properties: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponseProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "GroupQuotasEnforcementResponseProperties"}, - } - - def __init__( - self, *, properties: Optional["_models.GroupQuotasEnforcementResponseProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: - :paramtype properties: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponseProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class GroupQuotasEnforcementResponseProperties(_serialization.Model): - """GroupQuotasEnforcementResponseProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar enforcement_enabled: Is the GroupQuota Enforcement enabled for the Azure region. Known - values are: "Enabled", "Disabled", and "NotAvailable". - :vartype enforcement_enabled: str or ~azure.mgmt.quota.models.EnforcementState - :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 fault_code: Details of the failure. - :vartype fault_code: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "fault_code": {"readonly": True}, - } - - _attribute_map = { - "enforcement_enabled": {"key": "enforcementEnabled", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "fault_code": {"key": "faultCode", "type": "str"}, - } - - def __init__( - self, *, enforcement_enabled: Optional[Union[str, "_models.EnforcementState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword enforcement_enabled: Is the GroupQuota Enforcement enabled for the Azure region. Known - values are: "Enabled", "Disabled", and "NotAvailable". - :paramtype enforcement_enabled: str or ~azure.mgmt.quota.models.EnforcementState - """ - super().__init__(**kwargs) - self.enforcement_enabled = enforcement_enabled - self.provisioning_state = None - self.fault_code = None - - class GroupQuotasEntity(ProxyResource): """Properties and filters for ShareQuota. The request parameter is optional, if there are no filters specified. @@ -947,9 +754,8 @@ class GroupQuotasEntity(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.quota.models.SystemData - :ivar properties: Properties and filters for ShareQuota. The request parameter is optional, if - there are no filters specified. - :vartype properties: ~azure.mgmt.quota.models.GroupQuotasEntityBase + :ivar properties: Properties. + :vartype properties: ~azure.mgmt.quota.models.GroupQuotasEntityProperties """ _validation = { @@ -964,14 +770,13 @@ class GroupQuotasEntity(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "GroupQuotasEntityBase"}, + "properties": {"key": "properties", "type": "GroupQuotasEntityProperties"}, } - def __init__(self, *, properties: Optional["_models.GroupQuotasEntityBase"] = None, **kwargs: Any) -> None: + def __init__(self, *, properties: Optional["_models.GroupQuotasEntityProperties"] = None, **kwargs: Any) -> None: """ - :keyword properties: Properties and filters for ShareQuota. The request parameter is optional, - if there are no filters specified. - :paramtype properties: ~azure.mgmt.quota.models.GroupQuotasEntityBase + :keyword properties: Properties. + :paramtype properties: ~azure.mgmt.quota.models.GroupQuotasEntityProperties """ super().__init__(**kwargs) self.properties = properties @@ -985,9 +790,6 @@ class GroupQuotasEntityBase(_serialization.Model): :ivar display_name: Display name of the GroupQuota entity. :vartype display_name: str - :ivar additional_attributes: Additional attributes to filter/restrict the subscriptions, which - can be added to the subscriptionIds. - :vartype additional_attributes: ~azure.mgmt.quota.models.AdditionalAttributes :ivar provisioning_state: Provisioning state of the operation. Known values are: "Accepted", "Created", "Invalid", "Succeeded", "Failed", "InProgress", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState @@ -999,27 +801,16 @@ class GroupQuotasEntityBase(_serialization.Model): _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, - "additional_attributes": {"key": "additionalAttributes", "type": "AdditionalAttributes"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - display_name: Optional[str] = None, - additional_attributes: Optional["_models.AdditionalAttributes"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, display_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword display_name: Display name of the GroupQuota entity. :paramtype display_name: str - :keyword additional_attributes: Additional attributes to filter/restrict the subscriptions, - which can be added to the subscriptionIds. - :paramtype additional_attributes: ~azure.mgmt.quota.models.AdditionalAttributes """ super().__init__(**kwargs) self.display_name = display_name - self.additional_attributes = additional_attributes self.provisioning_state = None @@ -1031,9 +822,6 @@ class GroupQuotasEntityBasePatch(_serialization.Model): :ivar display_name: Display name of the GroupQuota entity. :vartype display_name: str - :ivar additional_attributes: Additional attributes to filter/restrict the subscriptions, which - can be added to the subscriptionIds. - :vartype additional_attributes: ~azure.mgmt.quota.models.AdditionalAttributesPatch :ivar provisioning_state: Provisioning state of the operation. Known values are: "Accepted", "Created", "Invalid", "Succeeded", "Failed", "InProgress", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState @@ -1045,27 +833,16 @@ class GroupQuotasEntityBasePatch(_serialization.Model): _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, - "additional_attributes": {"key": "additionalAttributes", "type": "AdditionalAttributesPatch"}, "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - display_name: Optional[str] = None, - additional_attributes: Optional["_models.AdditionalAttributesPatch"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, display_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword display_name: Display name of the GroupQuota entity. :paramtype display_name: str - :keyword additional_attributes: Additional attributes to filter/restrict the subscriptions, - which can be added to the subscriptionIds. - :paramtype additional_attributes: ~azure.mgmt.quota.models.AdditionalAttributesPatch """ super().__init__(**kwargs) self.display_name = display_name - self.additional_attributes = additional_attributes self.provisioning_state = None @@ -1086,9 +863,8 @@ class GroupQuotasEntityPatch(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.quota.models.SystemData - :ivar properties: Properties and filters for ShareQuota. The request parameter is optional, if - there are no filters specified. - :vartype properties: ~azure.mgmt.quota.models.GroupQuotasEntityBasePatch + :ivar properties: Properties. + :vartype properties: ~azure.mgmt.quota.models.GroupQuotasEntityPatchProperties """ _validation = { @@ -1103,19 +879,46 @@ class GroupQuotasEntityPatch(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "GroupQuotasEntityBasePatch"}, + "properties": {"key": "properties", "type": "GroupQuotasEntityPatchProperties"}, } - def __init__(self, *, properties: Optional["_models.GroupQuotasEntityBasePatch"] = None, **kwargs: Any) -> None: + def __init__( + self, *, properties: Optional["_models.GroupQuotasEntityPatchProperties"] = None, **kwargs: Any + ) -> None: """ - :keyword properties: Properties and filters for ShareQuota. The request parameter is optional, - if there are no filters specified. - :paramtype properties: ~azure.mgmt.quota.models.GroupQuotasEntityBasePatch + :keyword properties: Properties. + :paramtype properties: ~azure.mgmt.quota.models.GroupQuotasEntityPatchProperties """ super().__init__(**kwargs) self.properties = properties +class GroupQuotasEntityPatchProperties(GroupQuotasEntityBasePatch): + """Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: Display name of the GroupQuota entity. + :vartype display_name: str + :ivar provisioning_state: Provisioning state of the operation. Known values are: "Accepted", + "Created", "Invalid", "Succeeded", "Failed", "InProgress", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState + """ + + +class GroupQuotasEntityProperties(GroupQuotasEntityBase): + """Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: Display name of the GroupQuota entity. + :vartype display_name: str + :ivar provisioning_state: Provisioning state of the operation. Known values are: "Accepted", + "Created", "Invalid", "Succeeded", "Failed", "InProgress", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.quota.models.RequestState + """ + + class GroupQuotaSubscriptionId(ProxyResource): """This represents a Azure subscriptionId that is associated with a GroupQuotasEntity. @@ -1206,7 +1009,6 @@ class GroupQuotaSubscriptionIdProperties(_serialization.Model): """ _validation = { - "subscription_id": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -1215,10 +1017,13 @@ class GroupQuotaSubscriptionIdProperties(_serialization.Model): "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, subscription_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword subscription_id: An Azure subscriptionId. + :paramtype subscription_id: str + """ super().__init__(**kwargs) - self.subscription_id = None + self.subscription_id = subscription_id self.provisioning_state = None @@ -1980,7 +1785,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 @@ -2110,7 +1915,7 @@ def __init__( self.next_link = next_link -class QuotaRequestOneResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes +class QuotaRequestOneResourceProperties(_serialization.Model): """Quota request. Variables are only populated by the server, and will be ignored when sending a request. @@ -2137,7 +1942,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 +2138,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 +2735,33 @@ 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.SubscriptionQuotaAllocationsProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "SubscriptionQuotaAllocationsProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.SubscriptionQuotaAllocationsProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Quota properties for the specified resource. + :paramtype properties: ~azure.mgmt.quota.models.SubscriptionQuotaAllocationsProperties + """ + 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 +2775,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 +2791,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 +2820,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,49 +2836,60 @@ 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 -class SubscriptionQuotaAllocationsStatusList(_serialization.Model): - """Subscription quota allocation requests status list. +class SubscriptionQuotaDetails(_serialization.Model): + """Subscription Quota details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Subscription quota allocation status list. - :vartype value: list[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: 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. + :vartype shareable_quota: int + :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.SubscriptionQuotaDetailsName """ _validation = { - "next_link": {"readonly": True}, + "shareable_quota": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[SubmittedResourceRequestStatus]"}, - "next_link": {"key": "nextLink", "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, *, value: Optional[List["_models.SubmittedResourceRequestStatus"]] = None, **kwargs: Any - ) -> None: + def __init__(self, *, resource_name: Optional[str] = None, limit: Optional[int] = None, **kwargs: Any) -> None: """ - :keyword value: Subscription quota allocation status list. - :paramtype value: list[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :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.value = value - self.next_link = None + self.resource_name = resource_name + self.limit = limit + self.shareable_quota = None + self.name = None -class SubscriptionQuotaDetails(_serialization.Model): - """Subscription Quota details. +class SubscriptionQuotaAllocationsProperties(SubscriptionQuotaDetails): + """Quota properties for the specified resource. 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. @@ -3054,30 +2899,37 @@ class SubscriptionQuotaDetails(_serialization.Model): :vartype name: ~azure.mgmt.quota.models.SubscriptionQuotaDetailsName """ + +class SubscriptionQuotaAllocationsStatusList(_serialization.Model): + """Subscription quota allocation requests status list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Subscription quota allocation status list. + :vartype value: list[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + _validation = { - "shareable_quota": {"readonly": True}, - "name": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - "region": {"key": "region", "type": "str"}, - "limit": {"key": "limit", "type": "int"}, - "shareable_quota": {"key": "shareableQuota", "type": "int"}, - "name": {"key": "name", "type": "SubscriptionQuotaDetailsName"}, + "value": {"key": "value", "type": "[SubmittedResourceRequestStatus]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, region: Optional[str] = None, limit: Optional[int] = None, **kwargs: Any) -> None: + def __init__( + self, *, value: Optional[List["_models.SubmittedResourceRequestStatus"]] = None, **kwargs: Any + ) -> None: """ - :keyword region: Location/Azure region for the quota requested for resource. - :paramtype region: str - :keyword limit: The total quota limit for the subscription. - :paramtype limit: int + :keyword value: Subscription quota allocation status list. + :paramtype value: list[~azure.mgmt.quota.models.SubmittedResourceRequestStatus] """ super().__init__(**kwargs) - self.region = region - self.limit = limit - self.shareable_quota = None - self.name = None + self.value = value + self.next_link = None class SubscriptionQuotaDetailsName(_serialization.Model): @@ -3259,7 +3111,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/models/_quota_mgmt_client_enums.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_quota_mgmt_client_enums.py index 089b1b37bedf..1dbc3d00ea7d 100644 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_quota_mgmt_client_enums.py +++ b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/models/_quota_mgmt_client_enums.py @@ -19,28 +19,6 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" -class EnforcementState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enforcement status.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - NOT_AVAILABLE = "NotAvailable" - - -class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Environment name.""" - - NON_PRODUCTION = "NonProduction" - PRODUCTION = "Production" - - -class GroupingIdType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GroupingId type. It is a required property. More types of groupIds can be supported in future.""" - - SERVICE_TREE_ID = "ServiceTreeId" - BILLING_ID = "BillingId" - - class LimitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The limit object type.""" 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..7baec1eac569 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 @@ -5,39 +5,41 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -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_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations -from ._group_quota_usages_operations import GroupQuotaUsagesOperations -from ._group_quota_location_settings_operations import GroupQuotaLocationSettingsOperations -from ._usages_operations import UsagesOperations -from ._quota_operations import QuotaOperations -from ._quota_request_status_operations import QuotaRequestStatusOperations -from ._quota_operation_operations import QuotaOperationOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._group_quotas_operations import GroupQuotasOperations # type: ignore +from ._group_quota_subscriptions_operations import GroupQuotaSubscriptionsOperations # type: ignore +from ._group_quota_subscription_requests_operations import GroupQuotaSubscriptionRequestsOperations # type: ignore +from ._group_quota_limits_request_operations import GroupQuotaLimitsRequestOperations # type: ignore +from ._group_quota_limits_operations import GroupQuotaLimitsOperations # type: ignore +from ._group_quota_subscription_allocation_request_operations import GroupQuotaSubscriptionAllocationRequestOperations # type: ignore +from ._group_quota_subscription_allocation_operations import GroupQuotaSubscriptionAllocationOperations # type: ignore +from ._usages_operations import UsagesOperations # type: ignore +from ._quota_operations import QuotaOperations # type: ignore +from ._quota_request_status_operations import QuotaRequestStatusOperations # type: ignore +from ._quota_operation_operations import QuotaOperationOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "GroupQuotasOperations", "GroupQuotaSubscriptionsOperations", "GroupQuotaSubscriptionRequestsOperations", - "GroupQuotaLimitsOperations", "GroupQuotaLimitsRequestOperations", - "GroupQuotaSubscriptionAllocationOperations", + "GroupQuotaLimitsOperations", "GroupQuotaSubscriptionAllocationRequestOperations", - "GroupQuotaUsagesOperations", - "GroupQuotaLocationSettingsOperations", + "GroupQuotaSubscriptionAllocationOperations", "UsagesOperations", "QuotaOperations", "QuotaRequestStatusOperations", "QuotaOperationOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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..3ab461a3c9e6 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,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, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +16,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,69 +36,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-12-12")) 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 +63,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 +114,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,19 +132,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 +157,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..2740f5c6d9c6 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,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 @@ -30,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,66 +43,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-12-12")) 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 +71,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,7 +204,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 +213,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 +221,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 +229,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 +240,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 +256,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 +269,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 +292,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 +312,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 +335,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 +355,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 +376,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 +392,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 +401,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 +410,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 +428,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 +457,7 @@ def get( :rtype: ~azure.mgmt.quota.models.SubmittedResourceRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -777,7 +479,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -792,7 +493,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 +538,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +558,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 +573,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 deleted file mode 100644 index dcacb1e73bd7..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_location_settings_operations.py +++ /dev/null @@ -1,944 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# 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 io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - 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.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - management_group_id: str, group_quota_name: str, resource_provider_name: str, location: 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}/locationSettings/{location}", - ) # 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")) - 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}/locationSettings/{location}", - ) # 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")) - 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}/locationSettings/{location}", - ) # 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")) - 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}/locationSettings", - ) # 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}(? Union[_models.GroupQuotasEnforcementResponse, _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.GroupQuotasEnforcementResponse, _models.LROResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(location_settings, (IOBase, bytes)): - _content = location_settings - else: - if location_settings is not None: - _json = self._serialize.body(location_settings, "GroupQuotasEnforcementResponse") - 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, - location=location, - 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("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")) - 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, - location: str, - location_settings: Optional[_models.GroupQuotasEnforcementResponse] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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 GroupQuotasEnforcementResponse or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - 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, - location: str, - location_settings: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: 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 GroupQuotasEnforcementResponse or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - 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, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Is either a GroupQuotasEnforcementResponse type or a IO[bytes] type. Default value is - None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse or IO[bytes] - :return: An instance of LROPoller that returns either GroupQuotasEnforcementResponse or An - instance of LROPoller that returns either LROResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - 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.GroupQuotasEnforcementResponse] = 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, - location=location, - location_settings=location_settings, - 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("GroupQuotasEnforcementResponse", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.GroupQuotasEnforcementResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GroupQuotasEnforcementResponse]( - 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, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> Optional[_models.GroupQuotasEnforcementResponse]: - 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[Optional[_models.GroupQuotasEnforcementResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(location_settings, (IOBase, bytes)): - _content = location_settings - else: - if location_settings is not None: - _json = self._serialize.body(location_settings, "GroupQuotasEnforcementResponse") - else: - _json = None - - _request = build_update_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - location=location, - 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, 202]: - 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")) - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[_models.GroupQuotasEnforcementResponse] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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 GroupQuotasEnforcementResponse or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Default value is None. - :type location_settings: 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 GroupQuotasEnforcementResponse or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - management_group_id: str, - group_quota_name: str, - resource_provider_name: str, - location: str, - location_settings: Optional[Union[_models.GroupQuotasEnforcementResponse, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.GroupQuotasEnforcementResponse]: - """Enables the GroupQuotas enforcement settings for the resource provider and the location - specified. - - Enables the GroupQuotas enforcement for the resource provider and the location specified. The - resource provider will start using the group quotas as the overall quota for the subscriptions - included in the GroupQuota. The subscriptions cannot request quota at subscription level. - The subscriptions share the GroupQuotaLimits assigned to the GroupQuota. If the - GroupQuotaLimits is used, then submit a groupQuotaLimit request for the specific resource - - provider/location/resource. - Once the GroupQuota Enforcement is enabled then, it cannot be deleted or reverted back. To - disable GroupQuota Enforcement - - - - #. Remove all the subscriptions from the groupQuota using the delete API for Subscriptions - (Check the example - GroupQuotaSubscriptions_Delete). - #. Ten delete the GroupQuota (Check the example - GroupQuotas_Delete). - - :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 location: The name of the Azure region. Required. - :type location: str - :param location_settings: The GroupQuota body details for creation or update of a GroupQuota - entity. Is either a GroupQuotasEnforcementResponse type or a IO[bytes] type. Default value is - None. - :type location_settings: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse or IO[bytes] - :return: An instance of LROPoller that returns either GroupQuotasEnforcementResponse or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :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.GroupQuotasEnforcementResponse] = 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, - location=location, - location_settings=location_settings, - 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("GroupQuotasEnforcementResponse", 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, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.GroupQuotasEnforcementResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GroupQuotasEnforcementResponse]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, management_group_id: str, group_quota_name: str, resource_provider_name: str, location: str, **kwargs: Any - ) -> _models.GroupQuotasEnforcementResponse: - """Gets the GroupQuotas enforcement settings for the resource provider/location. - - Gets the GroupQuotas enforcement settings for the ResourceProvider/location. The locations, - where GroupQuota enforcement is not enabled will return Not Found. - - :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 location: The name of the Azure region. Required. - :type location: str - :return: GroupQuotasEnforcementResponse or the result of cls(response) - :rtype: ~azure.mgmt.quota.models.GroupQuotasEnforcementResponse - :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.GroupQuotasEnforcementResponse] = kwargs.pop("cls", None) - - _request = build_get_request( - management_group_id=management_group_id, - group_quota_name=group_quota_name, - resource_provider_name=resource_provider_name, - location=location, - 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("GroupQuotasEnforcementResponse", 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, **kwargs: Any - ) -> Iterable["_models.GroupQuotasEnforcementResponse"]: - """Returns a list of the Azure regions settings, where the GroupQuotas enforcement is enabled. - - Returns only the list of the Azure regions settings, where the GroupQuotas enforcement is - enabled. The locations not included in GroupQuota Enforcement will not be listed, the regions - in failed status with listed as status Failed. - - :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 - :return: An iterator like instance of either GroupQuotasEnforcementResponse or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.GroupQuotasEnforcementResponse] - :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.GroupQuotasEnforcementListResponse] = 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, - 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("GroupQuotasEnforcementListResponse", 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_subscription_allocation_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_subscription_allocation_operations.py index 825c0b450d30..1498a2d37f6c 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,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, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +16,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,60 +37,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-12-12")) 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 +63,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,19 +140,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 +166,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..054812baf0a3 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,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 @@ -30,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,61 +43,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-12-12")) + 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 +77,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-12-12")) 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 +126,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-12-12")) 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 +174,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +229,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 +237,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 +252,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 +287,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 +316,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 +360,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 +402,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 +419,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 +437,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 +455,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,35 +500,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 +525,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 +554,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 = { + 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..6ef349171b83 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +42,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +76,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +150,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,7 +168,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 +183,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 +236,7 @@ def get( :rtype: ~azure.mgmt.quota.models.GroupQuotaSubscriptionRequestStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,7 +258,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -273,7 +272,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..5d455ce7b412 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +5,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, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -15,13 +15,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 +30,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +48,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +83,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +118,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +153,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +186,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,8 +235,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +248,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 +258,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 +269,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 +285,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 +332,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 +360,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +373,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 +383,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 +394,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 +410,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 +455,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 +483,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +496,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 +506,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 +517,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 +533,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 +565,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 +574,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 +615,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +637,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 +651,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 +682,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -687,7 +700,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 +715,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 deleted file mode 100644 index 3379fe14f2b8..000000000000 --- a/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quota_usages_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - 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.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 - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - management_group_id: str, group_quota_name: str, resource_provider_name: str, location: 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}/locationUsages/{location}", - ) # 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}(? Iterable["_models.ResourceUsages"]: - """Gets the GroupQuotas usages and limits(quota) for the resourceProvider/location. - - Gets the GroupQuotas usages and limits(quota). Location is required paramter. - - :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 location: The name of the Azure region. Required. - :type location: str - :return: An iterator like instance of either ResourceUsages or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.quota.models.ResourceUsages] - :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.ResourceUsageList] = 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, - location=location, - 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("ResourceUsageList", 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_quotas_operations.py b/sdk/quota/azure-mgmt-quota/azure/mgmt/quota/operations/_group_quotas_operations.py index 1b15e85d1c91..96a124d54edc 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,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 @@ -30,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +47,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-12-12")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -78,7 +82,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-12-12")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -113,7 +117,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +149,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +181,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,8 +231,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,7 +245,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 +268,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 +279,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 +295,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 +429,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 +463,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,7 +477,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 +500,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 +511,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 +527,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 +665,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 +709,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -721,7 +730,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 +744,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,7 +764,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 +773,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 +784,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 +800,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 +832,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 +841,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 +884,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +901,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 +916,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..edfe2bf47266 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +42,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +92,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,7 +108,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 +123,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..f77e5c287aed 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,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, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,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 @@ -30,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +47,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +72,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-12-12")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -96,7 +100,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-12-12")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -124,7 +128,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,6 +169,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentQuotaLimitBase: + # pylint: disable=line-too-long """Get the quota limit of a resource. The response can be used to determine the remaining quota to calculate a new quota limit that can be submitted with a PUT request. @@ -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 = { 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 = { 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 @@ -305,6 +311,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -326,8 +333,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 @@ -350,6 +357,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -371,8 +379,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] @@ -393,6 +401,7 @@ def begin_create_or_update( create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Create or update the quota limit for the specified resource with the requested value. To update the quota, follow these steps: @@ -414,8 +423,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 +455,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 +489,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,7 +503,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 +523,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 +534,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 @@ -547,6 +559,7 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -567,8 +580,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 @@ -591,6 +604,7 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -611,8 +625,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] @@ -633,6 +647,7 @@ def begin_update( create_quota_request: Union[_models.CurrentQuotaLimitBase, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CurrentQuotaLimitBase]: + # pylint: disable=line-too-long """Update the quota limit for a specific resource to the specified value: @@ -653,8 +668,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 +700,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 @@ -714,14 +730,15 @@ def get_long_running_output(pipeline_response): @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentQuotaLimitBase"]: + # pylint: disable=line-too-long """Get a list of current quota limits of all resources for the specified scope. The response from this GET operation can be leveraged to submit requests to update a quota. :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 +751,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -751,7 +768,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 +783,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..1a02b9589c79 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +42,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +74,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,6 +121,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def get(self, id: str, scope: str, **kwargs: Any) -> _models.QuotaRequestDetails: + # pylint: disable=line-too-long """Get the quota request details and status by quota request ID for the resources of the resource provider at a specific location. The quota request ID **id** is returned in the response of the PUT operation. @@ -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 = { 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 @@ -187,14 +189,15 @@ def list( skiptoken: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.QuotaRequestDetails"]: + # pylint: disable=line-too-long """For the specified scope, get the current quota requests for a one year period ending at the time is made. Use the **oData** filter to select quota requests. :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 +228,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +248,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 +263,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..638f07aad1fa 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -19,16 +19,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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +42,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +67,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-12-12")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,6 +108,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentUsagesBase: + # pylint: disable=line-too-long """Get the current usage of a resource. :param resource_name: Resource name for a given resource provider. For example: @@ -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 = { 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 @@ -173,13 +175,14 @@ def get(self, resource_name: str, scope: str, **kwargs: Any) -> _models.CurrentU @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.CurrentUsagesBase"]: + # pylint: disable=line-too-long """Get a list of current usage for all resources for the scope specified. :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 +194,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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +211,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 +226,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..74eec6f32eb4 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/stable/2024-12-12/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..dd8c00746e4b 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/stable/2024-12-12/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..fad9a88917ce 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/stable/2024-12-12/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..506b3993c631 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/stable/2024-12-12/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..3ca34cfe3899 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/stable/2024-12-12/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..13c1b416eb74 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/stable/2024-12-12/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..a1c40a50b728 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/stable/2024-12-12/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..5117f93ec1f9 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/stable/2024-12-12/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..14536383d9ac 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/stable/2024-12-12/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..20cbb738f923 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/stable/2024-12-12/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..a13b2889e508 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/stable/2024-12-12/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..b6ad2b8af019 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/stable/2024-12-12/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..7e2f144db384 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/stable/2024-12-12/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..19feb93ff977 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/stable/2024-12-12/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..65e767299d62 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/stable/2024-12-12/examples/getQuotaRequestsHistory.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_limits/list_group_quota_limits_compute.py similarity index 86% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quota_usages/get_group_quota_usages.py rename to sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits/list_group_quota_limits_compute.py index bc1933186d0f..4effca66b3a9 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_limits/list_group_quota_limits_compute.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python get_group_quota_usages.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,16 +30,15 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.group_quota_usages.list( + response = client.group_quota_limits.list( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", location="westus", ) - for item in response: - print(item) + print(response) -# 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/stable/2024-12-12/examples/GroupQuotaLimits/ListGroupQuotaLimits-Compute.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_quota_limits_requests/group_quota_limits_requests_get.py similarity index 83% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/get_group_quota_enforcement.py rename to sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_get.py index f5a831eb29ee..9c62444eed1b 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_quota_limits_requests/group_quota_limits_requests_get.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python get_group_quota_enforcement.py + 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, @@ -30,15 +30,14 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.group_quota_location_settings.get( + response = client.group_quota_limits_request.get( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", - resource_provider_name="Microsoft.Compute", - location="eastus", + request_id_parameter="requestId", ) 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/stable/2024-12-12/examples/GroupQuotaLimitsRequests/GroupQuotaLimitsRequests_Get.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_quota_limits_requests/group_quota_limits_requests_list.py similarity index 86% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/list_group_quota_enforcement.py rename to sdk/quota/azure-mgmt-quota/generated_samples/group_quota_limits_requests/group_quota_limits_requests_list.py index 370bafd60457..77c6d61b8866 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_quota_limits_requests/group_quota_limits_requests_list.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python list_group_quota_enforcement.py + 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, @@ -30,15 +30,16 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.group_quota_location_settings.list( + response = client.group_quota_limits_request.list( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", resource_provider_name="Microsoft.Compute", + filter="location eq westus", ) for item in response: print(item) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/ListGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/stable/2024-12-12/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..f532f7dcccec 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/stable/2024-12-12/examples/GroupQuotaLimitsRequests/PatchGroupQuotaLimitsRequests-Compute.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..3a01d2de4ab8 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/stable/2024-12-12/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..02ef4e4bb1e9 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/stable/2024-12-12/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..a0994527b4f1 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/stable/2024-12-12/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..bcf033405377 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/stable/2024-12-12/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..ff86b7d181ff 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/stable/2024-12-12/examples/GroupQuotas/PutGroupQuotas.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 deleted file mode 100644 index 799470d1607b..000000000000 --- a/sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement_failed.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.quota import QuotaMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-quota -# USAGE - python put_group_quota_enforcement_failed.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_location_settings.begin_create_or_update( - management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", - group_quota_name="groupquota1", - resource_provider_name="Microsoft.Compute", - location="eastus", - ).result() - print(response) - - -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-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..083aeff92712 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/stable/2024-12-12/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..4e15e826ade0 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/stable/2024-12-12/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..2f0ef9e6c08e 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/stable/2024-12-12/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..894e44cc30c7 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/stable/2024-12-12/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..a0dc0dfbf4a4 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/stable/2024-12-12/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..7167e85c1618 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/stable/2024-12-12/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..bcfbc9daeb4c 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/stable/2024-12-12/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..08463a2f9be6 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/stable/2024-12-12/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..4f6daf6cfe8d 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/stable/2024-12-12/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..18c6c68b6f2c 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/stable/2024-12-12/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..95e736cb4519 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/stable/2024-12-12/examples/putNetworkOneSkuQuotaRequestStandardSkuPublicIpAddresses.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/subscription_quota_allocation/subscription_quota_allocation_list_compute.py similarity index 80% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/put_group_quota_enforcement.py rename to sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation/subscription_quota_allocation_list_compute.py index 2038a8b2dfa9..e53c2d5e0d39 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/subscription_quota_allocation/subscription_quota_allocation_list_compute.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python put_group_quota_enforcement.py + 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, @@ -27,18 +27,18 @@ def main(): client = QuotaMgmtClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.group_quota_location_settings.begin_create_or_update( + 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="eastus", - ).result() + location="westus", + ) 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/stable/2024-12-12/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..e9428014380d 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/stable/2024-12-12/examples/SubscriptionQuotaAllocationRequests/PatchSubscriptionQuotaAllocationRequest-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/put_subscription_quota_allocation_request_compute.py deleted file mode 100644 index 403032ea4440..000000000000 --- a/sdk/quota/azure-mgmt-quota/generated_samples/subscription_quota_allocation_requests/put_subscription_quota_allocation_request_compute.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, IO, Union - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.quota import QuotaMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-quota -# USAGE - python put_subscription_quota_allocation_request_compute.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = QuotaMgmtClient( - credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", - ) - - response = client.group_quota_subscription_allocation_request.begin_create_or_update( - 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) - - -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PutSubscriptionQuotaAllocationRequest-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..50723ee9a033 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/stable/2024-12-12/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_Get-Compute.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/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py similarity index 76% 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/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_compute.py index ff3fc743b593..f6f9dc801187 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/subscription_quota_allocation_requests/subscription_quota_allocation_requests_list_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 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, @@ -27,18 +27,19 @@ def main(): client = QuotaMgmtClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.group_quota_limits_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", - ).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/GroupQuotaLimitsRequests/PutGroupQuotaLimitsRequests-Compute.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/stable/2024-12-12/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_List-Compute.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/subscription_requests/subscription_requests_get.py similarity index 82% rename from sdk/quota/azure-mgmt-quota/generated_samples/group_quotas_enforcement/patch_group_quota_enforcement.py rename to sdk/quota/azure-mgmt-quota/generated_samples/subscription_requests/subscription_requests_get.py index f39d48ae8cb1..82f2cac48d8c 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/subscription_requests/subscription_requests_get.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-quota # USAGE - python patch_group_quota_enforcement.py + 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, @@ -30,15 +30,14 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.group_quota_location_settings.begin_update( + response = client.group_quota_subscription_requests.get( management_group_id="E7EC67B3-7657-4966-BFFC-41EFD36BAA09", group_quota_name="groupquota1", - resource_provider_name="Microsoft.Compute", - location="eastus", - ).result() + request_id_parameter="00000000-0000-0000-0000-000000000000", + ) print(response) -# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PatchGroupQuotaEnforcement.json +# x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/stable/2024-12-12/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..33b8c5a578af 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/stable/2024-12-12/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..40c13c29b825 --- /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() + + +# For security, please avoid 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..effd59f49d16 --- /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_group_quota_limits_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-12-12", + ) + + # 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..fe42e8c70012 --- /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_group_quota_limits_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-12-12", + ) + + # 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..71aba1813357 --- /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_group_quota_limits_request_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-12-12", + ).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_group_quota_limits_request_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-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_group_quota_limits_request_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-12-12", + ) + 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..537ca887d00a --- /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_group_quota_limits_request_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-12-12", + ) + ).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_group_quota_limits_request_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-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_group_quota_limits_request_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-12-12", + ) + 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..a861a5741d22 --- /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_group_quota_subscription_allocation_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-12-12", + ) + + # 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..24f18ed2ce21 --- /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_group_quota_subscription_allocation_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-12-12", + ) + + # 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..8965895c7145 --- /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_group_quota_subscription_allocation_request_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-12-12", + ).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_group_quota_subscription_allocation_request_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-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_group_quota_subscription_allocation_request_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-12-12", + ) + 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..cdc193820746 --- /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_group_quota_subscription_allocation_request_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-12-12", + ) + ).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_group_quota_subscription_allocation_request_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-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_group_quota_subscription_allocation_request_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-12-12", + ) + 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..dc203066840b --- /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_group_quota_subscription_requests_list(self, resource_group): + response = self.client.group_quota_subscription_requests.list( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_group_quota_subscription_requests_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-12-12", + ) + + # 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..cc6cd43a68b5 --- /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_group_quota_subscription_requests_list(self, resource_group): + response = self.client.group_quota_subscription_requests.list( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + 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_group_quota_subscription_requests_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-12-12", + ) + + # 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..f25ff9b98077 --- /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_group_quota_subscriptions_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-12-12", + ).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_group_quota_subscriptions_begin_update(self, resource_group): + response = self.client.group_quota_subscriptions.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ).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_group_quota_subscriptions_begin_delete(self, resource_group): + response = self.client.group_quota_subscriptions.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ).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_group_quota_subscriptions_get(self, resource_group): + response = self.client.group_quota_subscriptions.get( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_group_quota_subscriptions_list(self, resource_group): + response = self.client.group_quota_subscriptions.list( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + 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..bd619488715f --- /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_group_quota_subscriptions_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-12-12", + ) + ).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_group_quota_subscriptions_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-12-12", + ) + ).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_group_quota_subscriptions_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-12-12", + ) + ).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_group_quota_subscriptions_get(self, resource_group): + response = await self.client.group_quota_subscriptions.get( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_group_quota_subscriptions_list(self, resource_group): + response = self.client.group_quota_subscriptions.list( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + 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..e9640f82ec75 --- /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_group_quotas_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-12-12", + ).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_group_quotas_begin_update(self, resource_group): + response = self.client.group_quotas.begin_update( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ).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_group_quotas_get(self, resource_group): + response = self.client.group_quotas.get( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_group_quotas_begin_delete(self, resource_group): + response = self.client.group_quotas.begin_delete( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ).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_group_quotas_list(self, resource_group): + response = self.client.group_quotas.list( + management_group_id="str", + api_version="2024-12-12", + ) + 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..c3a0508123e3 --- /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_group_quotas_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-12-12", + ) + ).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_group_quotas_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-12-12", + ) + ).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_group_quotas_get(self, resource_group): + response = await self.client.group_quotas.get( + management_group_id="str", + group_quota_name="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_group_quotas_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-12-12", + ) + ).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_group_quotas_list(self, resource_group): + response = self.client.group_quotas.list( + management_group_id="str", + api_version="2024-12-12", + ) + 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..2f21cf09d1da --- /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_quota_operation_list(self, resource_group): + response = self.client.quota_operation.list( + api_version="2024-12-12", + ) + 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..c8c4d8c6133f --- /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_quota_operation_list(self, resource_group): + response = self.client.quota_operation.list( + api_version="2024-12-12", + ) + 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..1af6a9f61206 --- /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_quota_get(self, resource_group): + response = self.client.quota.get( + resource_name="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_quota_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-12-12", + ).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_quota_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-12-12", + ).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_quota_list(self, resource_group): + response = self.client.quota.list( + scope="str", + api_version="2024-12-12", + ) + 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..0b6eda36bc68 --- /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_quota_get(self, resource_group): + response = await self.client.quota.get( + resource_name="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_quota_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-12-12", + ) + ).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_quota_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-12-12", + ) + ).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_quota_list(self, resource_group): + response = self.client.quota.list( + scope="str", + api_version="2024-12-12", + ) + 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..948bd937432e --- /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_quota_request_status_get(self, resource_group): + response = self.client.quota_request_status.get( + id="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_quota_request_status_list(self, resource_group): + response = self.client.quota_request_status.list( + scope="str", + api_version="2024-12-12", + ) + 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..035882ca69e0 --- /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_quota_request_status_get(self, resource_group): + response = await self.client.quota_request_status.get( + id="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_quota_request_status_list(self, resource_group): + response = self.client.quota_request_status.list( + scope="str", + api_version="2024-12-12", + ) + 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..dca62a6e2d4f --- /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_usages_get(self, resource_group): + response = self.client.usages.get( + resource_name="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_usages_list(self, resource_group): + response = self.client.usages.list( + scope="str", + api_version="2024-12-12", + ) + 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..134b8dde86fb --- /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_usages_get(self, resource_group): + response = await self.client.usages.get( + resource_name="str", + scope="str", + api_version="2024-12-12", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_usages_list(self, resource_group): + response = self.client.usages.list( + scope="str", + api_version="2024-12-12", + ) + 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", ],