diff --git a/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md b/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md index 8b89179a7455..38f6a558db6e 100644 --- a/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md +++ b/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 2.0.0 (2025-05-12) + +### Features Added + + - Enum `ActionType` added member `CAPTCHA` + - Enum `MatchProcessingBehavior` added member `CONTINUE` + - Enum `Operator` added member `SERVICE_TAG_MATCH` + - Model `PolicySettings` added property `captcha_expiration_in_minutes` + +### Breaking Changes + + - Deleted or renamed enum value `MatchProcessingBehavior.CONTINUE_ENUM` + ## 1.2.0 (2024-04-15) ### Features Added diff --git a/sdk/network/azure-mgmt-frontdoor/README.md b/sdk/network/azure-mgmt-frontdoor/README.md index 5084bc9e2791..6e1c5ed20243 100644 --- a/sdk/network/azure-mgmt-frontdoor/README.md +++ b/sdk/network/azure-mgmt-frontdoor/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Front Door Service Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/network/azure-mgmt-frontdoor/_meta.json b/sdk/network/azure-mgmt-frontdoor/_meta.json index b627790ac506..3fe3ff11a950 100644 --- a/sdk/network/azure-mgmt-frontdoor/_meta.json +++ b/sdk/network/azure-mgmt-frontdoor/_meta.json @@ -1,11 +1,11 @@ { - "commit": "b54ffc9278eff071455b1dbb4ad2e772afce885d", + "commit": "3a040f7e6384068fd20771d8e40b070a86dc4ff3", "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.34.1", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/frontdoor/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/frontdoor/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.34.1 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/frontdoor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/__init__.py index 0c1489095479..8308501c5466 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/__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 ._front_door_management_client import FrontDoorManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._front_door_management_client import FrontDoorManagementClient # 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__ = [ "FrontDoorManagementClient", ] -__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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py index 82c6cc94b851..c0a0aba2fdee 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_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 FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for FrontDoorManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py index c0a8d575a4e2..59834745df70 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py @@ -7,16 +7,19 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from . import models as _models from ._configuration import FrontDoorManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( EndpointsOperations, ExperimentsOperations, @@ -33,7 +36,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -74,22 +76,24 @@ class FrontDoorManagementClient: # pylint: disable=client-accepts-api-version-k :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = FrontDoorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -108,7 +112,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -164,7 +168,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "FrontDoorManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_patch.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_patch.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/__init__.py similarity index 58% rename from sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py rename to sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/__init__.py index 0dafe0e287ff..0af9b28f6607 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/__init__.py @@ -4,13 +4,3 @@ # 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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/serialization.py similarity index 82% rename from sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py rename to sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/serialization.py index 2f781d740827..f5187701d7be 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -48,11 +30,8 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, - Mapping, ) try: @@ -62,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +70,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 +93,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 +125,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 +136,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 @@ -177,80 +165,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _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 +244,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 +280,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 +304,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 +340,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,30 +358,31 @@ 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 @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -424,9 +390,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 + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -446,21 +414,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 +471,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: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -538,7 +512,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 +532,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. + :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 +567,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 +610,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 +642,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 + :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 +681,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,11 +690,13 @@ 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 - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -726,21 +708,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 + :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 +738,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 + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -778,21 +760,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. + :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 +784,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 +800,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 +819,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 +852,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 +862,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 +923,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 +948,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 +956,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 +981,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 +1012,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 +1074,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 +1089,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. + :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 +1127,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. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1170,13 +1159,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 + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1184,11 +1174,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 +1199,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 +1222,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 +1281,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 +1333,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( + 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: @@ -1352,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1361,9 +1364,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, @@ -1399,27 +1402,29 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :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 :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :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 +1443,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 +1479,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 +1507,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 +1520,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 +1535,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 +1558,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,24 +1587,35 @@ 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() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] 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: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore 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 +1624,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. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1647,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 +1671,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 +1695,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,13 +1706,14 @@ 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. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1718,11 +1746,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,8 +1757,9 @@ 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. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1741,24 +1769,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 +1793,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 +1807,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 +1819,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 +1830,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,8 +1848,9 @@ 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. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1832,8 +1861,9 @@ 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. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1847,8 +1877,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1863,8 +1894,9 @@ 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. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1875,8 +1907,9 @@ 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. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1885,16 +1918,16 @@ 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. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1908,8 +1941,9 @@ 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. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1922,31 +1956,32 @@ 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. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) 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. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1974,8 +2009,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,8 +2017,9 @@ 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 + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore @@ -1994,5 +2029,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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py index dbf4c577231c..48944bf3938a 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.2.0" +VERSION = "2.0.0" diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/__init__.py index 4c19219bc359..05de63d20931 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/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 ._front_door_management_client import FrontDoorManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._front_door_management_client import FrontDoorManagementClient # 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__ = [ "FrontDoorManagementClient", ] -__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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py index c7db56dd2a97..10fe99d5a736 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/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 FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for FrontDoorManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py index 537f2340590f..7527960d5672 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py @@ -7,15 +7,18 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import FrontDoorManagementClientConfiguration from .operations import ( EndpointsOperations, @@ -33,7 +36,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -74,22 +76,24 @@ class FrontDoorManagementClient: # pylint: disable=client-accepts-api-version-k :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = FrontDoorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -108,7 +112,9 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -166,7 +172,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "FrontDoorManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_patch.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_patch.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/__init__.py index b9c0fbfebc8d..d8bfdd5c392f 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,24 +6,28 @@ # 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 ._policies_operations import PoliciesOperations -from ._managed_rule_sets_operations import ManagedRuleSetsOperations -from ._front_door_name_availability_operations import FrontDoorNameAvailabilityOperations -from ._front_door_name_availability_with_subscription_operations import ( - FrontDoorNameAvailabilityWithSubscriptionOperations, -) -from ._front_doors_operations import FrontDoorsOperations -from ._frontend_endpoints_operations import FrontendEndpointsOperations -from ._endpoints_operations import EndpointsOperations -from ._rules_engines_operations import RulesEnginesOperations -from ._network_experiment_profiles_operations import NetworkExperimentProfilesOperations -from ._preconfigured_endpoints_operations import PreconfiguredEndpointsOperations -from ._experiments_operations import ExperimentsOperations -from ._reports_operations import ReportsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policies_operations import PoliciesOperations # type: ignore +from ._managed_rule_sets_operations import ManagedRuleSetsOperations # type: ignore +from ._front_door_name_availability_operations import FrontDoorNameAvailabilityOperations # type: ignore +from ._front_door_name_availability_with_subscription_operations import FrontDoorNameAvailabilityWithSubscriptionOperations # type: ignore +from ._front_doors_operations import FrontDoorsOperations # type: ignore +from ._frontend_endpoints_operations import FrontendEndpointsOperations # type: ignore +from ._endpoints_operations import EndpointsOperations # type: ignore +from ._rules_engines_operations import RulesEnginesOperations # type: ignore +from ._network_experiment_profiles_operations import NetworkExperimentProfilesOperations # type: ignore +from ._preconfigured_endpoints_operations import PreconfiguredEndpointsOperations # type: ignore +from ._experiments_operations import ExperimentsOperations # type: ignore +from ._reports_operations import ReportsOperations # 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__ = [ @@ -39,5 +44,5 @@ "ExperimentsOperations", "ReportsOperations", ] -__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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py index 982524c3d80d..7a9c9a6ee1da 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_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,29 +5,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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_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 ..._utils.serialization import Deserializer, Serializer from ...operations._endpoints_operations import build_purge_content_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,19 +51,19 @@ class EndpointsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements + async def _purge_content_initial( self, resource_group_name: str, front_door_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -73,7 +76,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -94,10 +97,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme 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 ) @@ -105,12 +108,20 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload async def begin_purge_content( @@ -201,7 +212,7 @@ async def begin_purge_content( 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._purge_content_initial( # type: ignore + raw_result = await self._purge_content_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, content_file_paths=content_file_paths, @@ -212,6 +223,7 @@ async def begin_purge_content( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py index 5c8e2b119980..07d17a2dd6bd 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._experiments_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +39,7 @@ build_list_by_profile_request, build_update_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,10 +59,10 @@ class ExperimentsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_profile( @@ -83,7 +86,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ExperimentList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,12 +105,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -155,7 +156,7 @@ async def get( :rtype: ~azure.mgmt.frontdoor.models.Experiment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,7 +179,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -193,7 +193,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("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -207,8 +207,8 @@ async def _create_or_update_initial( experiment_name: str, parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any - ) -> _models.Experiment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,7 +221,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -243,10 +243,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 ) @@ -254,18 +254,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Experiment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -385,10 +382,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("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -417,8 +415,8 @@ async def _update_initial( experiment_name: str, parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any - ) -> _models.Experiment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,7 +429,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -453,10 +451,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 ) @@ -464,15 +462,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) - if response.status_code == 200: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Experiment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -592,10 +590,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("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -617,10 +616,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, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -632,7 +631,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", "2019-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -643,10 +642,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 ) @@ -654,12 +653,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -688,7 +695,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( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -698,6 +705,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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py index 9ffcee0a3b49..ad00930ade66 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,15 @@ 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_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 ..._utils.serialization import Deserializer, Serializer from ...operations._front_door_name_availability_operations import build_check_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,10 +47,10 @@ class FrontDoorNameAvailabilityOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def check( @@ -108,7 +109,7 @@ async def check( :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -139,7 +140,6 @@ async def check( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -154,7 +154,7 @@ async def check( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py index 0e919f8a2038..e9d200382b9b 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,15 @@ 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_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 ..._utils.serialization import Deserializer, Serializer from ...operations._front_door_name_availability_with_subscription_operations import build_check_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,10 +47,10 @@ class FrontDoorNameAvailabilityWithSubscriptionOperations: # pylint: disable=na 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def check( @@ -108,7 +109,7 @@ async def check( :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,7 +141,6 @@ async def check( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,7 +155,7 @@ async def check( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py index a1cb6ec9f7a5..eaa8c4a292d8 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._front_doors_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +40,7 @@ build_list_request, build_validate_custom_domain_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,10 +60,10 @@ class FrontDoorsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.FrontDoor"]: @@ -76,7 +79,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.FrontDoor"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,12 +96,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -144,7 +145,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,12 +163,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -210,7 +209,7 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An :rtype: ~azure.mgmt.frontdoor.models.FrontDoor :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -232,7 +231,6 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,7 +245,7 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("FrontDoor", pipeline_response) + deserialized = self._deserialize("FrontDoor", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -260,8 +258,8 @@ async def _create_or_update_initial( front_door_name: str, front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any - ) -> _models.FrontDoor: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,7 +272,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FrontDoor] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -295,10 +293,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 ) @@ -306,18 +304,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("FrontDoor", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("FrontDoor", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("FrontDoor", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -426,10 +421,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("FrontDoor", pipeline_response) + deserialized = self._deserialize("FrontDoor", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -454,10 +450,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, resource_group_name: str, front_door_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,7 +465,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", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -479,10 +475,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 ) @@ -490,12 +486,20 @@ 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -518,7 +522,7 @@ async def begin_delete(self, resource_group_name: str, front_door_name: str, **k 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( resource_group_name=resource_group_name, front_door_name=front_door_name, api_version=api_version, @@ -527,6 +531,7 @@ async def begin_delete(self, resource_group_name: str, front_door_name: str, **k 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 @@ -628,7 +633,7 @@ async def validate_custom_domain( :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,7 +667,6 @@ async def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -677,7 +681,7 @@ async def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py index c36b3943db39..3dd510108f46 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,13 +31,14 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._frontend_endpoints_operations import ( build_disable_https_request, build_enable_https_request, build_get_request, build_list_by_front_door_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,10 +58,10 @@ class FrontendEndpointsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_front_door( @@ -80,7 +83,7 @@ def list_by_front_door( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontendEndpointsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,12 +102,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -151,7 +152,7 @@ async def get( :rtype: ~azure.mgmt.frontdoor.models.FrontendEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,7 +175,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,22 +189,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("FrontendEndpoint", pipeline_response) + deserialized = self._deserialize("FrontendEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _enable_https_initial( # pylint: disable=inconsistent-return-statements + async def _enable_https_initial( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +217,7 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -239,10 +239,10 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen 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 ) @@ -250,12 +250,20 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload async def begin_enable_https( @@ -353,7 +361,7 @@ async def begin_enable_https( 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._enable_https_initial( # type: ignore + raw_result = await self._enable_https_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -365,6 +373,7 @@ async def begin_enable_https( 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 @@ -389,10 +398,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _disable_https_initial( # pylint: disable=inconsistent-return-statements + async def _disable_https_initial( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,7 +413,7 @@ async def _disable_https_initial( # pylint: disable=inconsistent-return-stateme _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_https_request( resource_group_name=resource_group_name, @@ -415,10 +424,10 @@ async def _disable_https_initial( # pylint: disable=inconsistent-return-stateme 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 ) @@ -426,12 +435,20 @@ async def _disable_https_initial( # pylint: disable=inconsistent-return-stateme 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_disable_https( @@ -459,7 +476,7 @@ async def begin_disable_https( 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._disable_https_initial( # type: ignore + raw_result = await self._disable_https_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -469,6 +486,7 @@ async def begin_disable_https( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py index 6192c507d92b..67808ee09f96 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_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,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,15 +19,15 @@ 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 ..._utils.serialization import Deserializer, Serializer from ...operations._managed_rule_sets_operations import build_list_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,10 +47,10 @@ class ManagedRuleSetsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition"]: @@ -64,10 +65,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,12 +85,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py index 9fd4f586e7cf..19cb155d5cca 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._network_experiment_profiles_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +40,7 @@ build_list_request, build_update_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,10 +60,10 @@ class NetworkExperimentProfilesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: @@ -78,7 +81,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ProfileList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,12 +98,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -148,7 +149,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ProfileList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,12 +167,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -215,7 +214,7 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) :rtype: ~azure.mgmt.frontdoor.models.Profile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,7 +236,6 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -252,7 +250,7 @@ async def get(self, resource_group_name: str, profile_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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -261,8 +259,8 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) async def _create_or_update_initial( self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -275,7 +273,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -296,10 +294,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 ) @@ -307,18 +305,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -424,10 +419,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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -455,8 +451,8 @@ async def _update_initial( profile_name: str, parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,7 +465,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -490,10 +486,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 ) @@ -501,15 +497,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) - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -619,10 +615,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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -644,10 +641,8 @@ 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 - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,7 +654,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", "2019-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -669,10 +664,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 ) @@ -680,12 +675,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -710,7 +713,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar 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( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -719,6 +722,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py index d1dc600da289..7f607a4f11a8 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policies_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +40,7 @@ build_list_request, build_update_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,10 +60,10 @@ class PoliciesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.WebApplicationFirewallPolicy"]: @@ -77,10 +80,10 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,12 +101,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -146,10 +147,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.WebAppli _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,12 +167,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -215,7 +214,7 @@ async def get( :rtype: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,7 +225,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) _request = build_get_request( @@ -237,7 +236,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -252,7 +250,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("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -265,8 +263,8 @@ async def _create_or_update_initial( policy_name: str, parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.WebApplicationFirewallPolicy: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,9 +275,9 @@ async def _create_or_update_initial( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -300,10 +298,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 ) @@ -311,18 +309,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -411,7 +406,7 @@ async def begin_create_or_update( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -429,10 +424,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("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -460,8 +456,8 @@ async def _update_initial( policy_name: str, parameters: Union[_models.TagsObject, IO[bytes]], **kwargs: Any - ) -> _models.WebApplicationFirewallPolicy: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,9 +468,9 @@ async def _update_initial( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -495,10 +491,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 ) @@ -506,11 +502,15 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200]: + 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 = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -602,7 +602,7 @@ async def begin_update( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -620,10 +620,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("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -645,10 +646,8 @@ 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 - self, resource_group_name: str, policy_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -659,8 +658,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -670,10 +669,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 ) @@ -681,11 +680,19 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -702,13 +709,13 @@ async def begin_delete(self, resource_group_name: str, policy_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[None] = 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, policy_name=policy_name, api_version=api_version, @@ -717,6 +724,7 @@ async def begin_delete(self, resource_group_name: str, policy_name: str, **kwarg 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py index 9c428146208c..6229db4aebf7 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_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,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,15 +19,15 @@ 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 ..._utils.serialization import Deserializer, Serializer from ...operations._preconfigured_endpoints_operations import build_list_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,10 +47,10 @@ class PreconfiguredEndpointsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -75,7 +76,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.PreconfiguredEndpointList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,12 +95,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py index cb47fb45b81a..a372c2e4a584 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,15 @@ 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_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 ..._utils.serialization import Deserializer, Serializer from ...operations._reports_operations import build_get_latency_scorecards_request, build_get_timeseries_request +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,10 +47,10 @@ class ReportsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_latency_scorecards( @@ -86,7 +87,7 @@ async def get_latency_scorecards( :rtype: ~azure.mgmt.frontdoor.models.LatencyScorecard :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,7 +113,6 @@ async def get_latency_scorecards( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -127,7 +127,7 @@ async def get_latency_scorecards( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LatencyScorecard", pipeline_response) + deserialized = self._deserialize("LatencyScorecard", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -177,7 +177,7 @@ async def get_timeseries( :rtype: ~azure.mgmt.frontdoor.models.Timeseries :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,7 +206,6 @@ async def get_timeseries( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,7 +220,7 @@ async def get_timeseries( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Timeseries", pipeline_response) + deserialized = self._deserialize("Timeseries", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py index b4dd75c5ff5a..10f1e60addbc 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,13 +31,14 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._rules_engines_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_front_door_request, ) +from .._configuration import FrontDoorManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,10 +58,10 @@ class RulesEnginesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_front_door( @@ -80,7 +83,7 @@ def list_by_front_door( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RulesEngineListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,12 +102,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -151,7 +152,7 @@ async def get( :rtype: ~azure.mgmt.frontdoor.models.RulesEngine :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,7 +175,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -189,7 +189,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("RulesEngine", pipeline_response) + deserialized = self._deserialize("RulesEngine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -203,8 +203,8 @@ async def _create_or_update_initial( rules_engine_name: str, rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any - ) -> _models.RulesEngine: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +217,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesEngine] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -239,10 +239,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 ) @@ -250,18 +250,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("RulesEngine", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RulesEngine", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("RulesEngine", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -383,10 +380,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("RulesEngine", pipeline_response) + deserialized = self._deserialize("RulesEngine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -411,10 +409,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, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,7 +424,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", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -437,10 +435,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 ) @@ -448,12 +446,20 @@ 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -481,7 +487,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( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_name, @@ -491,6 +497,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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py index 983f1c5f5df2..8894817aa628 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py @@ -5,156 +5,167 @@ # 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 AzureAsyncOperationResult -from ._models_py3 import Backend -from ._models_py3 import BackendPool -from ._models_py3 import BackendPoolListResult -from ._models_py3 import BackendPoolProperties -from ._models_py3 import BackendPoolUpdateParameters -from ._models_py3 import BackendPoolsSettings -from ._models_py3 import CacheConfiguration -from ._models_py3 import CheckNameAvailabilityInput -from ._models_py3 import CheckNameAvailabilityOutput -from ._models_py3 import CustomHttpsConfiguration -from ._models_py3 import CustomRule -from ._models_py3 import CustomRuleList -from ._models_py3 import DefaultErrorResponse -from ._models_py3 import DefaultErrorResponseError -from ._models_py3 import Endpoint -from ._models_py3 import Error -from ._models_py3 import ErrorDetails -from ._models_py3 import ErrorResponse -from ._models_py3 import Experiment -from ._models_py3 import ExperimentList -from ._models_py3 import ExperimentUpdateModel -from ._models_py3 import ForwardingConfiguration -from ._models_py3 import FrontDoor -from ._models_py3 import FrontDoorListResult -from ._models_py3 import FrontDoorProperties -from ._models_py3 import FrontDoorUpdateParameters -from ._models_py3 import FrontendEndpoint -from ._models_py3 import FrontendEndpointLink -from ._models_py3 import FrontendEndpointProperties -from ._models_py3 import FrontendEndpointUpdateParameters -from ._models_py3 import FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink -from ._models_py3 import FrontendEndpointsListResult -from ._models_py3 import GroupByVariable -from ._models_py3 import HeaderAction -from ._models_py3 import HealthProbeSettingsListResult -from ._models_py3 import HealthProbeSettingsModel -from ._models_py3 import HealthProbeSettingsProperties -from ._models_py3 import HealthProbeSettingsUpdateParameters -from ._models_py3 import KeyVaultCertificateSourceParametersVault -from ._models_py3 import LatencyMetric -from ._models_py3 import LatencyScorecard -from ._models_py3 import LoadBalancingSettingsListResult -from ._models_py3 import LoadBalancingSettingsModel -from ._models_py3 import LoadBalancingSettingsProperties -from ._models_py3 import LoadBalancingSettingsUpdateParameters -from ._models_py3 import ManagedRuleDefinition -from ._models_py3 import ManagedRuleExclusion -from ._models_py3 import ManagedRuleGroupDefinition -from ._models_py3 import ManagedRuleGroupOverride -from ._models_py3 import ManagedRuleOverride -from ._models_py3 import ManagedRuleSet -from ._models_py3 import ManagedRuleSetDefinition -from ._models_py3 import ManagedRuleSetDefinitionList -from ._models_py3 import ManagedRuleSetList -from ._models_py3 import MatchCondition -from ._models_py3 import PolicySettings -from ._models_py3 import PreconfiguredEndpoint -from ._models_py3 import PreconfiguredEndpointList -from ._models_py3 import Profile -from ._models_py3 import ProfileList -from ._models_py3 import ProfileUpdateModel -from ._models_py3 import PurgeParameters -from ._models_py3 import RedirectConfiguration -from ._models_py3 import Resource -from ._models_py3 import RouteConfiguration -from ._models_py3 import RoutingRule -from ._models_py3 import RoutingRuleLink -from ._models_py3 import RoutingRuleListResult -from ._models_py3 import RoutingRuleProperties -from ._models_py3 import RoutingRuleUpdateParameters -from ._models_py3 import RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink -from ._models_py3 import RulesEngine -from ._models_py3 import RulesEngineAction -from ._models_py3 import RulesEngineListResult -from ._models_py3 import RulesEngineMatchCondition -from ._models_py3 import RulesEngineProperties -from ._models_py3 import RulesEngineRule -from ._models_py3 import RulesEngineUpdateParameters -from ._models_py3 import SecurityPolicyLink -from ._models_py3 import Sku -from ._models_py3 import SubResource -from ._models_py3 import TagsObject -from ._models_py3 import Timeseries -from ._models_py3 import TimeseriesDataPoint -from ._models_py3 import ValidateCustomDomainInput -from ._models_py3 import ValidateCustomDomainOutput -from ._models_py3 import WebApplicationFirewallPolicy -from ._models_py3 import WebApplicationFirewallPolicyList -from ._models_py3 import WebApplicationFirewallScrubbingRules +from typing import TYPE_CHECKING -from ._front_door_management_client_enums import ActionType -from ._front_door_management_client_enums import AggregationInterval -from ._front_door_management_client_enums import Availability -from ._front_door_management_client_enums import BackendEnabledState -from ._front_door_management_client_enums import CustomHttpsProvisioningState -from ._front_door_management_client_enums import CustomHttpsProvisioningSubstate -from ._front_door_management_client_enums import CustomRuleEnabledState -from ._front_door_management_client_enums import DynamicCompressionEnabled -from ._front_door_management_client_enums import EndpointType -from ._front_door_management_client_enums import EnforceCertificateNameCheckEnabledState -from ._front_door_management_client_enums import FrontDoorCertificateSource -from ._front_door_management_client_enums import FrontDoorCertificateType -from ._front_door_management_client_enums import FrontDoorEnabledState -from ._front_door_management_client_enums import FrontDoorForwardingProtocol -from ._front_door_management_client_enums import FrontDoorHealthProbeMethod -from ._front_door_management_client_enums import FrontDoorProtocol -from ._front_door_management_client_enums import FrontDoorQuery -from ._front_door_management_client_enums import FrontDoorRedirectProtocol -from ._front_door_management_client_enums import FrontDoorRedirectType -from ._front_door_management_client_enums import FrontDoorResourceState -from ._front_door_management_client_enums import FrontDoorTlsProtocolType -from ._front_door_management_client_enums import HeaderActionType -from ._front_door_management_client_enums import HealthProbeEnabled -from ._front_door_management_client_enums import LatencyScorecardAggregationInterval -from ._front_door_management_client_enums import ManagedRuleEnabledState -from ._front_door_management_client_enums import ManagedRuleExclusionMatchVariable -from ._front_door_management_client_enums import ManagedRuleExclusionSelectorMatchOperator -from ._front_door_management_client_enums import ManagedRuleSetActionType -from ._front_door_management_client_enums import MatchProcessingBehavior -from ._front_door_management_client_enums import MatchVariable -from ._front_door_management_client_enums import MinimumTLSVersion -from ._front_door_management_client_enums import NetworkExperimentResourceState -from ._front_door_management_client_enums import NetworkOperationStatus -from ._front_door_management_client_enums import Operator -from ._front_door_management_client_enums import PolicyEnabledState -from ._front_door_management_client_enums import PolicyMode -from ._front_door_management_client_enums import PolicyRequestBodyCheck -from ._front_door_management_client_enums import PolicyResourceState -from ._front_door_management_client_enums import PrivateEndpointStatus -from ._front_door_management_client_enums import ResourceType -from ._front_door_management_client_enums import RoutingRuleEnabledState -from ._front_door_management_client_enums import RuleType -from ._front_door_management_client_enums import RulesEngineMatchVariable -from ._front_door_management_client_enums import RulesEngineOperator -from ._front_door_management_client_enums import ScrubbingRuleEntryMatchOperator -from ._front_door_management_client_enums import ScrubbingRuleEntryMatchVariable -from ._front_door_management_client_enums import ScrubbingRuleEntryState -from ._front_door_management_client_enums import SessionAffinityEnabledState -from ._front_door_management_client_enums import SkuName -from ._front_door_management_client_enums import State -from ._front_door_management_client_enums import TimeseriesAggregationInterval -from ._front_door_management_client_enums import TimeseriesType -from ._front_door_management_client_enums import Transform -from ._front_door_management_client_enums import TransformType -from ._front_door_management_client_enums import VariableName -from ._front_door_management_client_enums import WebApplicationFirewallScrubbingState +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AzureAsyncOperationResult, + Backend, + BackendPool, + BackendPoolListResult, + BackendPoolProperties, + BackendPoolUpdateParameters, + BackendPoolsSettings, + CacheConfiguration, + CheckNameAvailabilityInput, + CheckNameAvailabilityOutput, + CustomHttpsConfiguration, + CustomRule, + CustomRuleList, + DefaultErrorResponse, + DefaultErrorResponseError, + Endpoint, + Error, + ErrorDetails, + ErrorResponse, + Experiment, + ExperimentList, + ExperimentUpdateModel, + ForwardingConfiguration, + FrontDoor, + FrontDoorListResult, + FrontDoorProperties, + FrontDoorUpdateParameters, + FrontendEndpoint, + FrontendEndpointLink, + FrontendEndpointProperties, + FrontendEndpointUpdateParameters, + FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink, + FrontendEndpointsListResult, + GroupByVariable, + HeaderAction, + HealthProbeSettingsListResult, + HealthProbeSettingsModel, + HealthProbeSettingsProperties, + HealthProbeSettingsUpdateParameters, + KeyVaultCertificateSourceParametersVault, + LatencyMetric, + LatencyScorecard, + LoadBalancingSettingsListResult, + LoadBalancingSettingsModel, + LoadBalancingSettingsProperties, + LoadBalancingSettingsUpdateParameters, + ManagedRuleDefinition, + ManagedRuleExclusion, + ManagedRuleGroupDefinition, + ManagedRuleGroupOverride, + ManagedRuleOverride, + ManagedRuleSet, + ManagedRuleSetDefinition, + ManagedRuleSetDefinitionList, + ManagedRuleSetList, + MatchCondition, + PolicySettings, + PreconfiguredEndpoint, + PreconfiguredEndpointList, + Profile, + ProfileList, + ProfileUpdateModel, + PurgeParameters, + RedirectConfiguration, + Resource, + RouteConfiguration, + RoutingRule, + RoutingRuleLink, + RoutingRuleListResult, + RoutingRuleProperties, + RoutingRuleUpdateParameters, + RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink, + RulesEngine, + RulesEngineAction, + RulesEngineListResult, + RulesEngineMatchCondition, + RulesEngineProperties, + RulesEngineRule, + RulesEngineUpdateParameters, + SecurityPolicyLink, + Sku, + SubResource, + TagsObject, + Timeseries, + TimeseriesDataPoint, + ValidateCustomDomainInput, + ValidateCustomDomainOutput, + WebApplicationFirewallPolicy, + WebApplicationFirewallPolicyList, + WebApplicationFirewallScrubbingRules, +) + +from ._front_door_management_client_enums import ( # type: ignore + ActionType, + AggregationInterval, + Availability, + BackendEnabledState, + CustomHttpsProvisioningState, + CustomHttpsProvisioningSubstate, + CustomRuleEnabledState, + DynamicCompressionEnabled, + EndpointType, + EnforceCertificateNameCheckEnabledState, + FrontDoorCertificateSource, + FrontDoorCertificateType, + FrontDoorEnabledState, + FrontDoorForwardingProtocol, + FrontDoorHealthProbeMethod, + FrontDoorProtocol, + FrontDoorQuery, + FrontDoorRedirectProtocol, + FrontDoorRedirectType, + FrontDoorResourceState, + FrontDoorTlsProtocolType, + HeaderActionType, + HealthProbeEnabled, + LatencyScorecardAggregationInterval, + ManagedRuleEnabledState, + ManagedRuleExclusionMatchVariable, + ManagedRuleExclusionSelectorMatchOperator, + ManagedRuleSetActionType, + MatchProcessingBehavior, + MatchVariable, + MinimumTLSVersion, + NetworkExperimentResourceState, + NetworkOperationStatus, + Operator, + PolicyEnabledState, + PolicyMode, + PolicyRequestBodyCheck, + PolicyResourceState, + PrivateEndpointStatus, + ResourceType, + RoutingRuleEnabledState, + RuleType, + RulesEngineMatchVariable, + RulesEngineOperator, + ScrubbingRuleEntryMatchOperator, + ScrubbingRuleEntryMatchVariable, + ScrubbingRuleEntryState, + SessionAffinityEnabledState, + SkuName, + State, + TimeseriesAggregationInterval, + TimeseriesType, + Transform, + TransformType, + VariableName, + WebApplicationFirewallScrubbingState, +) 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__ = [ @@ -305,5 +316,5 @@ "VariableName", "WebApplicationFirewallScrubbingState", ] -__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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py index 74081edc4b78..29963ff8e93f 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py @@ -19,6 +19,7 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REDIRECT = "Redirect" ANOMALY_SCORING = "AnomalyScoring" JS_CHALLENGE = "JSChallenge" + CAPTCHA = "CAPTCHA" class AggregationInterval(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -260,8 +261,9 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE_ENUM = "Continue" + CONTINUE = "Continue" STOP = "Stop" + CONTINUE_ENUM = "Continue" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -321,6 +323,7 @@ class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): BEGINS_WITH = "BeginsWith" ENDS_WITH = "EndsWith" REG_EX = "RegEx" + SERVICE_TAG_MATCH = "ServiceTagMatch" class PolicyEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py index fb34615b08ec..7769b6826c6c 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/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. @@ -10,10 +10,9 @@ import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from .. import _serialization +from .._utils import serialization as _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -56,7 +55,7 @@ def __init__( self.error = error -class Backend(_serialization.Model): # pylint: disable=too-many-instance-attributes +class Backend(_serialization.Model): """Backend address of a frontDoor load balancer. Variables are only populated by the server, and will be ignored when sending a request. @@ -170,7 +169,7 @@ def __init__( self.private_link_alias = private_link_alias self.private_link_resource_id = private_link_resource_id self.private_link_location = private_link_location - self.private_endpoint_status = None + self.private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = None self.private_link_approval_message = private_link_approval_message self.http_port = http_port self.https_port = https_port @@ -261,11 +260,11 @@ def __init__( """ super().__init__(id=id, **kwargs) self.name = name - self.type = None + self.type: Optional[str] = None self.backends = backends self.load_balancing_settings = load_balancing_settings self.health_probe_settings = health_probe_settings - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class BackendPoolListResult(_serialization.Model): @@ -295,7 +294,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.BackendPool"]] = None self.next_link = next_link @@ -387,7 +386,7 @@ def __init__( health_probe_settings=health_probe_settings, **kwargs ) - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class BackendPoolsSettings(_serialization.Model): @@ -553,9 +552,9 @@ class CheckNameAvailabilityOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name_availability = None - self.reason = None - self.message = None + self.name_availability: Optional[Union[str, "_models.Availability"]] = None + self.reason: Optional[str] = None + self.message: Optional[str] = None class CustomHttpsConfiguration(_serialization.Model): @@ -672,7 +671,7 @@ class CustomRule(_serialization.Model): :ivar match_conditions: List of match conditions. Required. :vartype match_conditions: list[~azure.mgmt.frontdoor.models.MatchCondition] :ivar action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", "JSChallenge", and "CAPTCHA". :vartype action: str or ~azure.mgmt.frontdoor.models.ActionType """ @@ -734,7 +733,7 @@ def __init__( :keyword match_conditions: List of match conditions. Required. :paramtype match_conditions: list[~azure.mgmt.frontdoor.models.MatchCondition] :keyword action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", "JSChallenge", and "CAPTCHA". :paramtype action: str or ~azure.mgmt.frontdoor.models.ActionType """ super().__init__(**kwargs) @@ -814,8 +813,8 @@ class DefaultErrorResponseError(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None + self.code: Optional[str] = None + self.message: Optional[str] = None class Endpoint(_serialization.Model): @@ -956,8 +955,8 @@ class ErrorResponse(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None + self.code: Optional[str] = None + self.message: Optional[str] = None class Resource(_serialization.Model): @@ -999,14 +998,14 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.location = location self.tags = tags -class Experiment(Resource): # pylint: disable=too-many-instance-attributes +class Experiment(Resource): """Defines the properties of an Experiment. Variables are only populated by the server, and will be ignored when sending a request. @@ -1093,9 +1092,9 @@ def __init__( self.endpoint_a = endpoint_a self.endpoint_b = endpoint_b self.enabled_state = enabled_state - self.resource_state = None - self.status = None - self.script_file_uri = None + self.resource_state: Optional[Union[str, "_models.NetworkExperimentResourceState"]] = None + self.status: Optional[str] = None + self.script_file_uri: Optional[str] = None class ExperimentList(_serialization.Model): @@ -1125,7 +1124,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Experiment"]] = None self.next_link = next_link @@ -1262,7 +1261,7 @@ def __init__( self.backend_pool = backend_pool -class FrontDoor(Resource): # pylint: disable=too-many-instance-attributes +class FrontDoor(Resource): """Front Door represents a collection of backend endpoints to route traffic to along with rules that specify how traffic is sent there. @@ -1394,12 +1393,12 @@ def __init__( self.frontend_endpoints = frontend_endpoints self.backend_pools_settings = backend_pools_settings self.enabled_state = enabled_state - self.resource_state = None - self.provisioning_state = None - self.cname = None - self.frontdoor_id = None - self.rules_engines = None - self.extended_properties = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None + self.provisioning_state: Optional[str] = None + self.cname: Optional[str] = None + self.frontdoor_id: Optional[str] = None + self.rules_engines: Optional[List["_models.RulesEngine"]] = None + self.extended_properties: Optional[Dict[str, str]] = None class FrontDoorListResult(_serialization.Model): @@ -1429,7 +1428,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.FrontDoor"]] = None self.next_link = next_link @@ -1512,7 +1511,7 @@ def __init__( self.enabled_state = enabled_state -class FrontDoorProperties(FrontDoorUpdateParameters): # pylint: disable=too-many-instance-attributes +class FrontDoorProperties(FrontDoorUpdateParameters): """The JSON object that contains the properties required to create an endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -1621,15 +1620,15 @@ def __init__( enabled_state=enabled_state, **kwargs ) - self.resource_state = None - self.provisioning_state = None - self.cname = None - self.frontdoor_id = None - self.rules_engines = None - self.extended_properties = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None + self.provisioning_state: Optional[str] = None + self.cname: Optional[str] = None + self.frontdoor_id: Optional[str] = None + self.rules_engines: Optional[List["_models.RulesEngine"]] = None + self.extended_properties: Optional[Dict[str, str]] = None -class FrontendEndpoint(SubResource): # pylint: disable=too-many-instance-attributes +class FrontendEndpoint(SubResource): """A frontend endpoint used for routing. Variables are only populated by the server, and will be ignored when sending a request. @@ -1735,15 +1734,15 @@ def __init__( """ super().__init__(id=id, **kwargs) self.name = name - self.type = None + self.type: Optional[str] = None self.host_name = host_name self.session_affinity_enabled_state = session_affinity_enabled_state self.session_affinity_ttl_seconds = session_affinity_ttl_seconds self.web_application_firewall_policy_link = web_application_firewall_policy_link - self.resource_state = None - self.custom_https_provisioning_state = None - self.custom_https_provisioning_substate = None - self.custom_https_configuration = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None + self.custom_https_provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = None + self.custom_https_provisioning_substate: Optional[Union[str, "_models.CustomHttpsProvisioningSubstate"]] = None + self.custom_https_configuration: Optional["_models.CustomHttpsConfiguration"] = None class FrontendEndpointLink(_serialization.Model): @@ -1919,10 +1918,10 @@ def __init__( web_application_firewall_policy_link=web_application_firewall_policy_link, **kwargs ) - self.resource_state = None - self.custom_https_provisioning_state = None - self.custom_https_provisioning_substate = None - self.custom_https_configuration = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None + self.custom_https_provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = None + self.custom_https_provisioning_substate: Optional[Union[str, "_models.CustomHttpsProvisioningSubstate"]] = None + self.custom_https_configuration: Optional["_models.CustomHttpsConfiguration"] = None class FrontendEndpointsListResult(_serialization.Model): @@ -1952,7 +1951,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.FrontendEndpoint"]] = None self.next_link = next_link @@ -2083,7 +2082,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.HealthProbeSettingsModel"]] = None self.next_link = next_link @@ -2166,13 +2165,13 @@ def __init__( """ super().__init__(id=id, **kwargs) self.name = name - self.type = None + self.type: Optional[str] = None self.path = path self.protocol = protocol self.interval_in_seconds = interval_in_seconds self.health_probe_method = health_probe_method self.enabled_state = enabled_state - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class HealthProbeSettingsUpdateParameters(_serialization.Model): @@ -2303,7 +2302,7 @@ def __init__( enabled_state=enabled_state, **kwargs ) - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class KeyVaultCertificateSourceParametersVault(_serialization.Model): @@ -2382,19 +2381,19 @@ class LatencyMetric(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name = None - self.end_date_time_utc = None - self.a_value = None - self.b_value = None - self.delta = None - self.delta_percent = None - self.a_c_lower95_ci = None - self.a_h_upper95_ci = None - self.b_c_lower95_ci = None - self.b_upper95_ci = None - - -class LatencyScorecard(Resource): # pylint: disable=too-many-instance-attributes + self.name: Optional[str] = None + self.end_date_time_utc: Optional[str] = None + self.a_value: Optional[float] = None + self.b_value: Optional[float] = None + self.delta: Optional[float] = None + self.delta_percent: Optional[float] = None + self.a_c_lower95_ci: Optional[float] = None + self.a_h_upper95_ci: Optional[float] = None + self.b_c_lower95_ci: Optional[float] = None + self.b_upper95_ci: Optional[float] = None + + +class LatencyScorecard(Resource): """Defines the LatencyScorecard. Variables are only populated by the server, and will be ignored when sending a request. @@ -2478,14 +2477,14 @@ def __init__( :paramtype latency_metrics: list[~azure.mgmt.frontdoor.models.LatencyMetric] """ super().__init__(location=location, tags=tags, **kwargs) - self.id_properties_id = None - self.name_properties_name = None - self.description = None - self.endpoint_a = None - self.endpoint_b = None - self.start_date_time_utc = None - self.end_date_time_utc = None - self.country = None + self.id_properties_id: Optional[str] = None + self.name_properties_name: Optional[str] = None + self.description: Optional[str] = None + self.endpoint_a: Optional[str] = None + self.endpoint_b: Optional[str] = None + self.start_date_time_utc: Optional[datetime.datetime] = None + self.end_date_time_utc: Optional[datetime.datetime] = None + self.country: Optional[str] = None self.latency_metrics = latency_metrics @@ -2516,7 +2515,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.LoadBalancingSettingsModel"]] = None self.next_link = next_link @@ -2585,11 +2584,11 @@ def __init__( """ super().__init__(id=id, **kwargs) self.name = name - self.type = None + self.type: Optional[str] = None self.sample_size = sample_size self.successful_samples_required = successful_samples_required self.additional_latency_milliseconds = additional_latency_milliseconds - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class LoadBalancingSettingsUpdateParameters(_serialization.Model): @@ -2688,7 +2687,7 @@ def __init__( additional_latency_milliseconds=additional_latency_milliseconds, **kwargs ) - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class ManagedRuleDefinition(_serialization.Model): @@ -2702,7 +2701,8 @@ class ManagedRuleDefinition(_serialization.Model): "Disabled" and "Enabled". :vartype default_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :ivar default_action: Describes the default action to be applied when the managed rule matches. - Known values are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". + Known values are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", "JSChallenge", and + "CAPTCHA". :vartype default_action: str or ~azure.mgmt.frontdoor.models.ActionType :ivar description: Describes the functionality of the managed rule. :vartype description: str @@ -2725,10 +2725,10 @@ class ManagedRuleDefinition(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.rule_id = None - self.default_state = None - self.default_action = None - self.description = None + self.rule_id: Optional[str] = None + self.default_state: Optional[Union[str, "_models.ManagedRuleEnabledState"]] = None + self.default_action: Optional[Union[str, "_models.ActionType"]] = None + self.description: Optional[str] = None class ManagedRuleExclusion(_serialization.Model): @@ -2819,9 +2819,9 @@ class ManagedRuleGroupDefinition(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.rule_group_name = None - self.description = None - self.rules = None + self.rule_group_name: Optional[str] = None + self.description: Optional[str] = None + self.rules: Optional[List["_models.ManagedRuleDefinition"]] = None class ManagedRuleGroupOverride(_serialization.Model): @@ -2882,7 +2882,7 @@ class ManagedRuleOverride(_serialization.Model): Disabled if not specified. Known values are: "Disabled" and "Enabled". :vartype enabled_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :ivar action: Describes the override action to be applied when rule matches. Known values are: - "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". + "Allow", "Block", "Log", "Redirect", "AnomalyScoring", "JSChallenge", and "CAPTCHA". :vartype action: str or ~azure.mgmt.frontdoor.models.ActionType :ivar exclusions: Describes the exclusions that are applied to this specific rule. :vartype exclusions: list[~azure.mgmt.frontdoor.models.ManagedRuleExclusion] @@ -2915,7 +2915,7 @@ def __init__( to Disabled if not specified. Known values are: "Disabled" and "Enabled". :paramtype enabled_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :keyword action: Describes the override action to be applied when rule matches. Known values - are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", "JSChallenge", and "CAPTCHA". :paramtype action: str or ~azure.mgmt.frontdoor.models.ActionType :keyword exclusions: Describes the exclusions that are applied to this specific rule. :paramtype exclusions: list[~azure.mgmt.frontdoor.models.ManagedRuleExclusion] @@ -3048,11 +3048,11 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s :paramtype tags: dict[str, str] """ super().__init__(location=location, tags=tags, **kwargs) - self.provisioning_state = None - self.rule_set_id = None - self.rule_set_type = None - self.rule_set_version = None - self.rule_groups = None + self.provisioning_state: Optional[str] = None + self.rule_set_id: Optional[str] = None + self.rule_set_type: Optional[str] = None + self.rule_set_version: Optional[str] = None + self.rule_groups: Optional[List["_models.ManagedRuleGroupDefinition"]] = None class ManagedRuleSetDefinitionList(_serialization.Model): @@ -3081,7 +3081,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.ManagedRuleSetDefinition"]] = None self.next_link = next_link @@ -3119,7 +3119,8 @@ class MatchCondition(_serialization.Model): :vartype selector: str :ivar operator: Comparison type to use for matching with the variable value. Required. Known values are: "Any", "IPMatch", "GeoMatch", "Equal", "Contains", "LessThan", "GreaterThan", - "LessThanOrEqual", "GreaterThanOrEqual", "BeginsWith", "EndsWith", and "RegEx". + "LessThanOrEqual", "GreaterThanOrEqual", "BeginsWith", "EndsWith", "RegEx", and + "ServiceTagMatch". :vartype operator: str or ~azure.mgmt.frontdoor.models.Operator :ivar negate_condition: Describes if the result of this condition should be negated. :vartype negate_condition: bool @@ -3165,7 +3166,8 @@ def __init__( :paramtype selector: str :keyword operator: Comparison type to use for matching with the variable value. Required. Known values are: "Any", "IPMatch", "GeoMatch", "Equal", "Contains", "LessThan", "GreaterThan", - "LessThanOrEqual", "GreaterThanOrEqual", "BeginsWith", "EndsWith", and "RegEx". + "LessThanOrEqual", "GreaterThanOrEqual", "BeginsWith", "EndsWith", "RegEx", and + "ServiceTagMatch". :paramtype operator: str or ~azure.mgmt.frontdoor.models.Operator :keyword negate_condition: Describes if the result of this condition should be negated. :paramtype negate_condition: bool @@ -3208,6 +3210,10 @@ class PolicySettings(_serialization.Model): validity lifetime in minutes. This setting is only applicable to Premium_AzureFrontDoor. Value must be an integer between 5 and 1440 with the default value being 30. :vartype javascript_challenge_expiration_in_minutes: int + :ivar captcha_expiration_in_minutes: Defines the Captcha cookie validity lifetime in minutes. + This setting is only applicable to Premium_AzureFrontDoor. Value must be an integer between 5 + and 1440 with the default value being 30. + :vartype captcha_expiration_in_minutes: int :ivar state: State of the log scrubbing config. Default value is Enabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingState @@ -3222,6 +3228,7 @@ class PolicySettings(_serialization.Model): "pattern": r"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$" }, "javascript_challenge_expiration_in_minutes": {"maximum": 1440, "minimum": 5}, + "captcha_expiration_in_minutes": {"maximum": 1440, "minimum": 5}, } _attribute_map = { @@ -3232,6 +3239,7 @@ class PolicySettings(_serialization.Model): "custom_block_response_body": {"key": "customBlockResponseBody", "type": "str"}, "request_body_check": {"key": "requestBodyCheck", "type": "str"}, "javascript_challenge_expiration_in_minutes": {"key": "javascriptChallengeExpirationInMinutes", "type": "int"}, + "captcha_expiration_in_minutes": {"key": "captchaExpirationInMinutes", "type": "int"}, "state": {"key": "logScrubbing.state", "type": "str"}, "scrubbing_rules": {"key": "logScrubbing.scrubbingRules", "type": "[WebApplicationFirewallScrubbingRules]"}, } @@ -3246,6 +3254,7 @@ def __init__( custom_block_response_body: Optional[str] = None, request_body_check: Optional[Union[str, "_models.PolicyRequestBodyCheck"]] = None, javascript_challenge_expiration_in_minutes: Optional[int] = None, + captcha_expiration_in_minutes: Optional[int] = None, state: Optional[Union[str, "_models.WebApplicationFirewallScrubbingState"]] = None, scrubbing_rules: Optional[List["_models.WebApplicationFirewallScrubbingRules"]] = None, **kwargs: Any @@ -3273,6 +3282,10 @@ def __init__( validity lifetime in minutes. This setting is only applicable to Premium_AzureFrontDoor. Value must be an integer between 5 and 1440 with the default value being 30. :paramtype javascript_challenge_expiration_in_minutes: int + :keyword captcha_expiration_in_minutes: Defines the Captcha cookie validity lifetime in + minutes. This setting is only applicable to Premium_AzureFrontDoor. Value must be an integer + between 5 and 1440 with the default value being 30. + :paramtype captcha_expiration_in_minutes: int :keyword state: State of the log scrubbing config. Default value is Enabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingState @@ -3289,6 +3302,7 @@ def __init__( self.custom_block_response_body = custom_block_response_body self.request_body_check = request_body_check self.javascript_challenge_expiration_in_minutes = javascript_challenge_expiration_in_minutes + self.captcha_expiration_in_minutes = captcha_expiration_in_minutes self.state = state self.scrubbing_rules = scrubbing_rules @@ -3396,7 +3410,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.PreconfiguredEndpoint"]] = None self.next_link = next_link @@ -3464,7 +3478,7 @@ def __init__( """ super().__init__(location=location, tags=tags, **kwargs) self.etag = etag - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.NetworkExperimentResourceState"]] = None self.enabled_state = enabled_state @@ -3495,7 +3509,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.Profile"]] = None self.next_link = next_link @@ -3585,9 +3599,9 @@ class RedirectConfiguration(RouteConfiguration): :vartype custom_fragment: str :ivar custom_query_string: The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query - string. Query string must be in :code:``=:code:`` format. The first ? and & will be - added automatically so do not include them in the front, but do separate multiple query strings - with &. + string. Query string must be in :code:``=\\ :code:`` format. The first ? and & will + be added automatically so do not include them in the front, but do separate multiple query + strings with &. :vartype custom_query_string: str """ @@ -3634,8 +3648,8 @@ def __init__( :paramtype custom_fragment: str :keyword custom_query_string: The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the - incoming query string. Query string must be in :code:``=:code:`` format. The first - ? and & will be added automatically so do not include them in the front, but do separate + incoming query string. Query string must be in :code:``=\\ :code:`` format. The + first ? and & will be added automatically so do not include them in the front, but do separate multiple query strings with &. :paramtype custom_query_string: str """ @@ -3649,7 +3663,7 @@ def __init__( self.custom_query_string = custom_query_string -class RoutingRule(SubResource): # pylint: disable=too-many-instance-attributes +class RoutingRule(SubResource): """A routing rule represents a specification for traffic to treat and where to send it, along with health probe information. @@ -3748,7 +3762,7 @@ def __init__( """ super().__init__(id=id, **kwargs) self.name = name - self.type = None + self.type: Optional[str] = None self.frontend_endpoints = frontend_endpoints self.accepted_protocols = accepted_protocols self.patterns_to_match = patterns_to_match @@ -3756,7 +3770,7 @@ def __init__( self.route_configuration = route_configuration self.rules_engine = rules_engine self.web_application_firewall_policy_link = web_application_firewall_policy_link - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class RoutingRuleLink(_serialization.Model): @@ -3806,7 +3820,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.RoutingRule"]] = None self.next_link = next_link @@ -3980,7 +3994,7 @@ def __init__( web_application_firewall_policy_link=web_application_firewall_policy_link, **kwargs ) - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink( @@ -4045,11 +4059,11 @@ def __init__(self, *, rules: Optional[List["_models.RulesEngineRule"]] = None, * :paramtype rules: list[~azure.mgmt.frontdoor.models.RulesEngineRule] """ super().__init__(**kwargs) - self.name = None - self.type = None - self.id = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.id: Optional[str] = None self.rules = rules - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class RulesEngineAction(_serialization.Model): @@ -4122,7 +4136,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.RulesEngine"]] = None self.next_link = next_link @@ -4257,7 +4271,7 @@ def __init__(self, *, rules: Optional[List["_models.RulesEngineRule"]] = None, * :paramtype rules: list[~azure.mgmt.frontdoor.models.RulesEngineRule] """ super().__init__(rules=rules, **kwargs) - self.resource_state = None + self.resource_state: Optional[Union[str, "_models.FrontDoorResourceState"]] = None class RulesEngineRule(_serialization.Model): @@ -4279,7 +4293,7 @@ class RulesEngineRule(_serialization.Model): :vartype match_conditions: list[~azure.mgmt.frontdoor.models.RulesEngineMatchCondition] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.frontdoor.models.MatchProcessingBehavior """ @@ -4320,7 +4334,7 @@ def __init__( :paramtype match_conditions: list[~azure.mgmt.frontdoor.models.RulesEngineMatchCondition] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.frontdoor.models.MatchProcessingBehavior """ @@ -4394,7 +4408,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class Timeseries(Resource): # pylint: disable=too-many-instance-attributes +class Timeseries(Resource): """Defines the Timeseries. Variables are only populated by the server, and will be ignored when sending a request. @@ -4576,12 +4590,12 @@ class ValidateCustomDomainOutput(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.custom_domain_validated = None - self.reason = None - self.message = None + self.custom_domain_validated: Optional[bool] = None + self.reason: Optional[str] = None + self.message: Optional[str] = None -class WebApplicationFirewallPolicy(Resource): # pylint: disable=too-many-instance-attributes +class WebApplicationFirewallPolicy(Resource): """Defines web application firewall policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -4687,11 +4701,11 @@ def __init__( self.policy_settings = policy_settings self.custom_rules = custom_rules self.managed_rules = managed_rules - self.frontend_endpoint_links = None - self.routing_rule_links = None - self.security_policy_links = None - self.provisioning_state = None - self.resource_state = None + self.frontend_endpoint_links: Optional[List["_models.FrontendEndpointLink"]] = None + self.routing_rule_links: Optional[List["_models.RoutingRuleLink"]] = None + self.security_policy_links: Optional[List["_models.SecurityPolicyLink"]] = None + self.provisioning_state: Optional[str] = None + self.resource_state: Optional[Union[str, "_models.PolicyResourceState"]] = None class WebApplicationFirewallPolicyList(_serialization.Model): @@ -4723,7 +4737,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: :paramtype next_link: str """ super().__init__(**kwargs) - self.value = None + self.value: Optional[List["_models.WebApplicationFirewallPolicy"]] = None self.next_link = next_link diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/__init__.py index b9c0fbfebc8d..d8bfdd5c392f 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,24 +6,28 @@ # 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 ._policies_operations import PoliciesOperations -from ._managed_rule_sets_operations import ManagedRuleSetsOperations -from ._front_door_name_availability_operations import FrontDoorNameAvailabilityOperations -from ._front_door_name_availability_with_subscription_operations import ( - FrontDoorNameAvailabilityWithSubscriptionOperations, -) -from ._front_doors_operations import FrontDoorsOperations -from ._frontend_endpoints_operations import FrontendEndpointsOperations -from ._endpoints_operations import EndpointsOperations -from ._rules_engines_operations import RulesEnginesOperations -from ._network_experiment_profiles_operations import NetworkExperimentProfilesOperations -from ._preconfigured_endpoints_operations import PreconfiguredEndpointsOperations -from ._experiments_operations import ExperimentsOperations -from ._reports_operations import ReportsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policies_operations import PoliciesOperations # type: ignore +from ._managed_rule_sets_operations import ManagedRuleSetsOperations # type: ignore +from ._front_door_name_availability_operations import FrontDoorNameAvailabilityOperations # type: ignore +from ._front_door_name_availability_with_subscription_operations import FrontDoorNameAvailabilityWithSubscriptionOperations # type: ignore +from ._front_doors_operations import FrontDoorsOperations # type: ignore +from ._frontend_endpoints_operations import FrontendEndpointsOperations # type: ignore +from ._endpoints_operations import EndpointsOperations # type: ignore +from ._rules_engines_operations import RulesEnginesOperations # type: ignore +from ._network_experiment_profiles_operations import NetworkExperimentProfilesOperations # type: ignore +from ._preconfigured_endpoints_operations import PreconfiguredEndpointsOperations # type: ignore +from ._experiments_operations import ExperimentsOperations # type: ignore +from ._reports_operations import ReportsOperations # 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__ = [ @@ -39,5 +44,5 @@ "ExperimentsOperations", "ReportsOperations", ] -__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/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py index 3a21fb0ba015..cdbb5d15a81f 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,29 +6,32 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_purge_content_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -99,19 +102,19 @@ class EndpointsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _purge_content_initial( # pylint: disable=inconsistent-return-statements + def _purge_content_initial( self, resource_group_name: str, front_door_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +127,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -145,10 +148,10 @@ def _purge_content_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 ) @@ -156,12 +159,20 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload def begin_purge_content( @@ -252,7 +263,7 @@ def begin_purge_content( 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._purge_content_initial( # type: ignore + raw_result = self._purge_content_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, content_file_paths=content_file_paths, @@ -263,6 +274,7 @@ def begin_purge_content( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py index 1cbefebda2d9..49b227ded2d0 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_profile_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -89,7 +92,7 @@ def build_get_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -131,7 +134,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -175,7 +178,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -218,7 +221,7 @@ def build_delete_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -260,10 +263,10 @@ class ExperimentsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_profile( @@ -287,7 +290,7 @@ def list_by_profile( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ExperimentList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,12 +309,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -359,7 +360,7 @@ def get( :rtype: ~azure.mgmt.frontdoor.models.Experiment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,7 +383,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -397,7 +397,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -411,8 +411,8 @@ def _create_or_update_initial( experiment_name: str, parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any - ) -> _models.Experiment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -425,7 +425,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -447,10 +447,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 ) @@ -458,18 +458,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Experiment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -586,10 +583,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("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -618,8 +616,8 @@ def _update_initial( experiment_name: str, parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any - ) -> _models.Experiment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -632,7 +630,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -654,10 +652,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 ) @@ -665,15 +663,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) - if response.status_code == 200: - deserialized = self._deserialize("Experiment", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Experiment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -790,10 +788,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("Experiment", pipeline_response) + deserialized = self._deserialize("Experiment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -815,10 +814,10 @@ 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 + def _delete_initial( self, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,7 +829,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", "2019-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -841,10 +840,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 ) @@ -852,12 +851,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -886,7 +893,7 @@ 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 = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -896,6 +903,7 @@ def begin_delete( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py index 1193024e8889..ef1b13808c55 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ map_error, ) 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 +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,10 +71,10 @@ class FrontDoorNameAvailabilityOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def check( @@ -133,7 +133,7 @@ def check( :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -164,7 +164,6 @@ def check( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -179,7 +178,7 @@ def check( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py index dbef341ed3bc..354613ada2d0 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_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,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ map_error, ) 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 +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +46,7 @@ def build_check_request(subscription_id: str, **kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -78,10 +78,10 @@ class FrontDoorNameAvailabilityWithSubscriptionOperations: # pylint: disable=na def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def check( @@ -140,7 +140,7 @@ def check( :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,7 +172,6 @@ def check( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -187,7 +186,7 @@ def check( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py index af249fc4905e..57bdb5a5da1b 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +76,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -110,7 +113,7 @@ def build_get_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -156,7 +159,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -203,7 +206,7 @@ def build_delete_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -249,7 +252,7 @@ def build_validate_custom_domain_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/validateCustomDomain", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -297,10 +300,10 @@ class FrontDoorsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.FrontDoor"]: @@ -316,7 +319,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.FrontDoor"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -333,12 +336,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -384,7 +385,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -402,12 +403,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -450,7 +449,7 @@ def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> :rtype: ~azure.mgmt.frontdoor.models.FrontDoor :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,7 +471,6 @@ def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,7 +485,7 @@ def get(self, resource_group_name: str, front_door_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("FrontDoor", pipeline_response) + deserialized = self._deserialize("FrontDoor", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -500,8 +498,8 @@ def _create_or_update_initial( front_door_name: str, front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any - ) -> _models.FrontDoor: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,7 +512,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FrontDoor] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -535,10 +533,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 ) @@ -546,18 +544,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("FrontDoor", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("FrontDoor", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("FrontDoor", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -663,10 +658,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("FrontDoor", pipeline_response) + deserialized = self._deserialize("FrontDoor", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -690,10 +686,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, resource_group_name: str, front_door_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -705,7 +699,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", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -715,10 +709,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 ) @@ -726,12 +720,20 @@ 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> LROPoller[None]: @@ -754,7 +756,7 @@ def begin_delete(self, resource_group_name: str, front_door_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( resource_group_name=resource_group_name, front_door_name=front_door_name, api_version=api_version, @@ -763,6 +765,7 @@ def begin_delete(self, resource_group_name: str, front_door_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 @@ -863,7 +866,7 @@ def validate_custom_domain( :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -897,7 +900,6 @@ def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -912,7 +914,7 @@ def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py index 937f13bd4f58..dc911ffe10c6 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_front_door_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -96,7 +99,7 @@ def build_get_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -150,7 +153,7 @@ def build_enable_https_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -205,7 +208,7 @@ def build_disable_https_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -259,10 +262,10 @@ class FrontendEndpointsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_front_door( @@ -284,7 +287,7 @@ def list_by_front_door( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontendEndpointsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,12 +306,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -355,7 +356,7 @@ def get( :rtype: ~azure.mgmt.frontdoor.models.FrontendEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,7 +379,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -393,22 +393,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("FrontendEndpoint", pipeline_response) + deserialized = self._deserialize("FrontendEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _enable_https_initial( # pylint: disable=inconsistent-return-statements + def _enable_https_initial( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,7 +421,7 @@ def _enable_https_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -443,10 +443,10 @@ def _enable_https_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 ) @@ -454,12 +454,20 @@ def _enable_https_initial( # pylint: disable=inconsistent-return-statements 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload def begin_enable_https( @@ -557,7 +565,7 @@ def begin_enable_https( 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._enable_https_initial( # type: ignore + raw_result = self._enable_https_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -569,6 +577,7 @@ def begin_enable_https( 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 @@ -592,10 +601,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _disable_https_initial( # pylint: disable=inconsistent-return-statements + def _disable_https_initial( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -607,7 +616,7 @@ def _disable_https_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", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_https_request( resource_group_name=resource_group_name, @@ -618,10 +627,10 @@ def _disable_https_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 ) @@ -629,12 +638,20 @@ def _disable_https_initial( # pylint: disable=inconsistent-return-statements 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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_disable_https( @@ -662,7 +679,7 @@ def begin_disable_https( 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._disable_https_initial( # type: ignore + raw_result = self._disable_https_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -672,6 +689,7 @@ def begin_disable_https( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py index 59b4df7e2a81..f8af770d8ef8 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_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,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ ) 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 +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,14 +39,14 @@ def build_list_request(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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallManagedRuleSets", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -76,10 +76,10 @@ class ManagedRuleSetsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: @@ -93,10 +93,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,12 +113,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py index f61eabf039ae..fc967b108bd5 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/NetworkExperimentProfiles" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -75,7 +78,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -110,7 +113,7 @@ def build_get_request(resource_group_name: str, profile_name: str, subscription_ _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -149,7 +152,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -190,7 +193,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -230,7 +233,7 @@ def build_delete_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -269,10 +272,10 @@ class NetworkExperimentProfilesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: @@ -290,7 +293,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ProfileList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,12 +310,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -360,7 +361,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.ProfileList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,12 +379,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -427,7 +426,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.frontdoor.models.Profile :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,7 +448,6 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -464,7 +462,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -473,8 +471,8 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo def _create_or_update_initial( self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -487,7 +485,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -508,10 +506,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 ) @@ -519,18 +517,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -633,10 +628,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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -664,8 +660,8 @@ def _update_initial( profile_name: str, parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any - ) -> _models.Profile: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -678,7 +674,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -699,10 +695,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 ) @@ -710,15 +706,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) - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -825,10 +821,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("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -850,10 +847,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, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,7 +860,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", "2019-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -875,10 +870,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 ) @@ -886,12 +881,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -916,7 +919,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An 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( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -925,6 +928,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py index ed5a02a35285..cc2541ccd7bb 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,14 +45,14 @@ def build_list_request(resource_group_name: str, subscription_id: 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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -77,14 +80,14 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -104,14 +107,14 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -142,7 +145,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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -150,7 +153,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -183,7 +186,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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +194,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -223,12 +226,12 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", @@ -264,10 +267,10 @@ class PoliciesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.WebApplicationFirewallPolicy"]: @@ -283,10 +286,10 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Web _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,12 +307,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -351,10 +352,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.WebApplicatio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,12 +372,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -418,7 +417,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod :rtype: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,7 +428,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) _request = build_get_request( @@ -440,7 +439,6 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -455,7 +453,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -468,8 +466,8 @@ def _create_or_update_initial( policy_name: str, parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.WebApplicationFirewallPolicy: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -480,9 +478,9 @@ def _create_or_update_initial( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -503,10 +501,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 ) @@ -514,18 +512,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -614,7 +609,7 @@ def begin_create_or_update( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -632,10 +627,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("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -663,8 +659,8 @@ def _update_initial( policy_name: str, parameters: Union[_models.TagsObject, IO[bytes]], **kwargs: Any - ) -> _models.WebApplicationFirewallPolicy: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,9 +671,9 @@ def _update_initial( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -698,10 +694,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 ) @@ -709,11 +705,15 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200]: + 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 = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -805,7 +805,7 @@ def begin_update( _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", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -823,10 +823,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("WebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -848,10 +849,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, resource_group_name: str, policy_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -862,8 +861,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -873,10 +872,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 ) @@ -884,11 +883,19 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> LROPoller[None]: @@ -905,13 +912,13 @@ def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-05-01")) cls: ClsType[None] = 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, policy_name=policy_name, api_version=api_version, @@ -920,6 +927,7 @@ def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any 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 diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py index 43705f16ff85..d002e58546e3 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +20,14 @@ ) 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 +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +47,7 @@ def build_list_request(resource_group_name: str, profile_name: str, subscription _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/PreconfiguredEndpoints", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -85,10 +86,10 @@ class PreconfiguredEndpointsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -113,7 +114,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.PreconfiguredEndpointList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,12 +133,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py index 9fa26fdcb3ac..efae34be7ef2 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +20,14 @@ map_error, ) 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 +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +57,7 @@ def build_get_latency_scorecards_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/LatencyScorecard", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -113,7 +114,7 @@ def build_get_timeseries_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/Timeseries", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -163,10 +164,10 @@ class ReportsOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_latency_scorecards( @@ -203,7 +204,7 @@ def get_latency_scorecards( :rtype: ~azure.mgmt.frontdoor.models.LatencyScorecard :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,7 +230,6 @@ def get_latency_scorecards( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -244,7 +244,7 @@ def get_latency_scorecards( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LatencyScorecard", pipeline_response) + deserialized = self._deserialize("LatencyScorecard", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -294,7 +294,7 @@ def get_timeseries( :rtype: ~azure.mgmt.frontdoor.models.Timeseries :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +323,6 @@ def get_timeseries( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -338,7 +337,7 @@ def get_timeseries( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Timeseries", pipeline_response) + deserialized = self._deserialize("Timeseries", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py index ba2236ab7094..cfa6dc004fe5 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,30 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, 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 from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import FrontDoorManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_front_door_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -96,7 +99,7 @@ def build_get_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -150,7 +153,7 @@ def build_create_or_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -205,7 +208,7 @@ def build_delete_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -259,10 +262,10 @@ class RulesEnginesOperations: def __init__(self, *args, **kwargs): input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: FrontDoorManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_front_door( @@ -284,7 +287,7 @@ def list_by_front_door( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RulesEngineListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,12 +306,10 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: _request = HttpRequest("GET", next_link) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -355,7 +356,7 @@ def get( :rtype: ~azure.mgmt.frontdoor.models.RulesEngine :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,7 +379,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -393,7 +393,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RulesEngine", pipeline_response) + deserialized = self._deserialize("RulesEngine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -407,8 +407,8 @@ def _create_or_update_initial( rules_engine_name: str, rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any - ) -> _models.RulesEngine: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,7 +421,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RulesEngine] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -443,10 +443,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 ) @@ -454,18 +454,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 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) - if response.status_code == 200: - deserialized = self._deserialize("RulesEngine", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RulesEngine", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("RulesEngine", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -587,10 +584,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("RulesEngine", pipeline_response) + deserialized = self._deserialize("RulesEngine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -614,10 +612,10 @@ 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 + def _delete_initial( self, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,7 +627,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", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -640,10 +638,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 ) @@ -651,12 +649,20 @@ 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -684,7 +690,7 @@ 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 = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_name, @@ -694,6 +700,7 @@ def begin_delete( 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 diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py index 4f99d4e53ea9..9a7917fd1fe9 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py index 903af2045d1f..a8ec54da5658 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py index ebdd529b3739..3a5223e067c2 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py index 22853ac7c535..e0d7294f22c0 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py index 029289832097..32aabea2657d 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py index ab3e4d177582..93db04f50618 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py index 9d029c39c4ae..80f711138877 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py index 9dfeb9f7b211..fc232e59eaf1 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py index ee8365823547..1d77e0f94f80 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py index 702c1019c01a..a241eca80dce 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py index 3f94145cbe09..cef5ff8e80c7 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py index 994d70a2849f..bd82f971e9e2 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py index ea6d403fc419..85f9045aff02 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py index ddbaf154633c..d6660f933bfe 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py index 8860ee134109..7d4e3a528a80 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py index 39e679e8d7d9..77d14ab75adc 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py index b45eea8e5192..4be490484c37 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py index e74a5c9e1654..98fbb2ca8796 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py index 3ee6e0c4cbed..f103978cb53c 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py index 232b119ae663..5c96007fa0ae 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py index fd2a1b33a8ab..e4909a9283e7 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py index 54b21dba2add..d5f2ef96b1c1 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py index ffbeefb1a5d5..b1d739347167 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,15 +7,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.frontdoor import FrontDoorManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py index 3bd3e73a6b6f..4ec10cd9c943 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py index 1600033b5275..3c28fe6f5700 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py index 18bbdee75cc3..fd9613335e3d 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.frontdoor import FrontDoorManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py index 8106acc16b98..abaff82cd399 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py index 8080f1fd22ae..28204620634a 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py index 2599fcfbdf77..2b984f6c89b9 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py index 478e97c702a2..5b73db6622d9 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py index 6b22b9763d69..4995bc6d0733 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListManagedRuleSets.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafListManagedRuleSets.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py index 319b5042109e..bfa87a809762 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPolicies.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py index 65250ae16c3a..5d5543a25bcc 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPoliciesUnderSubscription.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafListPoliciesUnderSubscription.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py index 6f7a07ca8e23..adc2c6a1830e 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient @@ -70,6 +69,20 @@ def main(): "priority": 2, "ruleType": "MatchRule", }, + { + "action": "CAPTCHA", + "matchConditions": [ + { + "matchValue": ["AzureBackup", "AzureBotService"], + "matchVariable": "RemoteAddr", + "operator": "ServiceTagMatch", + } + ], + "name": "Rule3", + "priority": 1, + "rateLimitThreshold": 1000, + "ruleType": "RateLimitRule", + }, ] }, "managedRules": { @@ -116,6 +129,7 @@ def main(): ] }, "policySettings": { + "captchaExpirationInMinutes": 30, "customBlockResponseBody": "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg==", "customBlockResponseStatusCode": 429, "enabledState": "Enabled", @@ -142,6 +156,6 @@ def main(): print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py index 145e322b321f..4a01ad7d01a3 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyDelete.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafPolicyDelete.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py index 070e5a31d879..b8b230f04213 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyGet.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py index 07616c834393..bf5b5d95bba7 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +7,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.frontdoor import FrontDoorManagementClient @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyPatch.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2025-05-01/examples/WafPolicyPatch.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/conftest.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/conftest.py new file mode 100644 index 000000000000..f0b651beba2a --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/conftest.py @@ -0,0 +1,37 @@ +# 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): + frontdoormanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + frontdoormanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + frontdoormanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + frontdoormanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=frontdoormanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=frontdoormanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=frontdoormanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=frontdoormanagement_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/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations.py new file mode 100644 index 000000000000..0c1dfd170fb5 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations.py @@ -0,0 +1,32 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_begin_purge_content(self, resource_group): + response = self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + front_door_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations_async.py new file mode 100644 index 000000000000..92e892f657d5 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_endpoints_operations_async.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 pytest +from azure.mgmt.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_endpoints_begin_purge_content(self, resource_group): + response = await ( + await self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + front_door_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations.py new file mode 100644 index 000000000000..dc123eeebc50 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations.py @@ -0,0 +1,98 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementExperimentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_experiments_list_by_profile(self, resource_group): + response = self.client.experiments.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_experiments_get(self, resource_group): + response = self.client.experiments.get( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_experiments_begin_create_or_update(self, resource_group): + response = self.client.experiments.begin_create_or_update( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + parameters={ + "description": "str", + "enabledState": "str", + "endpointA": {"endpoint": "str", "name": "str"}, + "endpointB": {"endpoint": "str", "name": "str"}, + "id": "str", + "location": "str", + "name": "str", + "resourceState": "str", + "scriptFileUri": "str", + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-11-01", + ).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_experiments_begin_update(self, resource_group): + response = self.client.experiments.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + parameters={"description": "str", "enabledState": "str", "tags": {"str": "str"}}, + api_version="2019-11-01", + ).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_experiments_begin_delete(self, resource_group): + response = self.client.experiments.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + api_version="2019-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations_async.py new file mode 100644 index 000000000000..d91d3b5147c3 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_experiments_operations_async.py @@ -0,0 +1,105 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementExperimentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_experiments_list_by_profile(self, resource_group): + response = self.client.experiments.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + 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_experiments_get(self, resource_group): + response = await self.client.experiments.get( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_experiments_begin_create_or_update(self, resource_group): + response = await ( + await self.client.experiments.begin_create_or_update( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + parameters={ + "description": "str", + "enabledState": "str", + "endpointA": {"endpoint": "str", "name": "str"}, + "endpointB": {"endpoint": "str", "name": "str"}, + "id": "str", + "location": "str", + "name": "str", + "resourceState": "str", + "scriptFileUri": "str", + "status": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-11-01", + ) + ).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_experiments_begin_update(self, resource_group): + response = await ( + await self.client.experiments.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + parameters={"description": "str", "enabledState": "str", "tags": {"str": "str"}}, + api_version="2019-11-01", + ) + ).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_experiments_begin_delete(self, resource_group): + response = await ( + await self.client.experiments.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + api_version="2019-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations.py new file mode 100644 index 000000000000..66c1ab678106 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations.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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorNameAvailabilityOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_door_name_availability_check(self, resource_group): + response = self.client.front_door_name_availability.check( + check_front_door_name_availability_input={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations_async.py new file mode 100644 index 000000000000..5da99eb75b07 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_operations_async.py @@ -0,0 +1,31 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorNameAvailabilityOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_front_door_name_availability_check(self, resource_group): + response = await self.client.front_door_name_availability.check( + check_front_door_name_availability_input={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations.py new file mode 100644 index 000000000000..94ec69a92a36 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations.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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorNameAvailabilityWithSubscriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_door_name_availability_with_subscription_check(self, resource_group): + response = self.client.front_door_name_availability_with_subscription.check( + check_front_door_name_availability_input={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations_async.py new file mode 100644 index 000000000000..816a100d9044 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_door_name_availability_with_subscription_operations_async.py @@ -0,0 +1,31 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorNameAvailabilityWithSubscriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_front_door_name_availability_with_subscription_check(self, resource_group): + response = await self.client.front_door_name_availability_with_subscription.check( + check_front_door_name_availability_input={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations.py new file mode 100644 index 000000000000..bdf05379c7bf --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations.py @@ -0,0 +1,226 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_doors_list(self, resource_group): + response = self.client.front_doors.list( + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_doors_list_by_resource_group(self, resource_group): + response = self.client.front_doors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_doors_get(self, resource_group): + response = self.client.front_doors.get( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_front_doors_begin_create_or_update(self, resource_group): + response = self.client.front_doors.begin_create_or_update( + resource_group_name=resource_group.name, + front_door_name="str", + front_door_parameters={ + "backendPools": [ + { + "backends": [ + { + "address": "str", + "backendHostHeader": "str", + "enabledState": "str", + "httpPort": 0, + "httpsPort": 0, + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "healthProbeSettings": {"id": "str"}, + "id": "str", + "loadBalancingSettings": {"id": "str"}, + "name": "str", + "resourceState": "str", + "type": "str", + } + ], + "backendPoolsSettings": {"enforceCertificateNameCheck": "Enabled", "sendRecvTimeoutSeconds": 0}, + "cname": "str", + "enabledState": "str", + "extendedProperties": {"str": "str"}, + "friendlyName": "str", + "frontdoorId": "str", + "frontendEndpoints": [ + { + "customHttpsConfiguration": { + "certificateSource": "str", + "minimumTlsVersion": "str", + "protocolType": "str", + "certificateType": "str", + "secretName": "str", + "secretVersion": "str", + "vault": {"id": "str"}, + }, + "customHttpsProvisioningState": "str", + "customHttpsProvisioningSubstate": "str", + "hostName": "str", + "id": "str", + "name": "str", + "resourceState": "str", + "sessionAffinityEnabledState": "str", + "sessionAffinityTtlSeconds": 0, + "type": "str", + "webApplicationFirewallPolicyLink": {"id": "str"}, + } + ], + "healthProbeSettings": [ + { + "enabledState": "str", + "healthProbeMethod": "HEAD", + "id": "str", + "intervalInSeconds": 0, + "name": "str", + "path": "str", + "protocol": "str", + "resourceState": "str", + "type": "str", + } + ], + "id": "str", + "loadBalancingSettings": [ + { + "additionalLatencyMilliseconds": 0, + "id": "str", + "name": "str", + "resourceState": "str", + "sampleSize": 0, + "successfulSamplesRequired": 0, + "type": "str", + } + ], + "location": "str", + "name": "str", + "provisioningState": "str", + "resourceState": "str", + "routingRules": [ + { + "acceptedProtocols": ["str"], + "enabledState": "str", + "frontendEndpoints": [{"id": "str"}], + "id": "str", + "name": "str", + "patternsToMatch": ["str"], + "resourceState": "str", + "routeConfiguration": "route_configuration", + "rulesEngine": {"id": "str"}, + "type": "str", + "webApplicationFirewallPolicyLink": {"id": "str"}, + } + ], + "rulesEngines": [ + { + "id": "str", + "name": "str", + "resourceState": "str", + "rules": [ + { + "action": { + "requestHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "responseHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "routeConfigurationOverride": "route_configuration", + }, + "name": "str", + "priority": 0, + "matchConditions": [ + { + "rulesEngineMatchValue": ["str"], + "rulesEngineMatchVariable": "str", + "rulesEngineOperator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "matchProcessingBehavior": "str", + } + ], + "type": "str", + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ).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_front_doors_begin_delete(self, resource_group): + response = self.client.front_doors.begin_delete( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ).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_front_doors_validate_custom_domain(self, resource_group): + response = self.client.front_doors.validate_custom_domain( + resource_group_name=resource_group.name, + front_door_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations_async.py new file mode 100644 index 000000000000..76929a3f3ca0 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_front_doors_operations_async.py @@ -0,0 +1,231 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontDoorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_front_doors_list(self, resource_group): + response = self.client.front_doors.list( + api_version="2021-06-01", + ) + 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_front_doors_list_by_resource_group(self, resource_group): + response = self.client.front_doors.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + 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_front_doors_get(self, resource_group): + response = await self.client.front_doors.get( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_front_doors_begin_create_or_update(self, resource_group): + response = await ( + await self.client.front_doors.begin_create_or_update( + resource_group_name=resource_group.name, + front_door_name="str", + front_door_parameters={ + "backendPools": [ + { + "backends": [ + { + "address": "str", + "backendHostHeader": "str", + "enabledState": "str", + "httpPort": 0, + "httpsPort": 0, + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "healthProbeSettings": {"id": "str"}, + "id": "str", + "loadBalancingSettings": {"id": "str"}, + "name": "str", + "resourceState": "str", + "type": "str", + } + ], + "backendPoolsSettings": {"enforceCertificateNameCheck": "Enabled", "sendRecvTimeoutSeconds": 0}, + "cname": "str", + "enabledState": "str", + "extendedProperties": {"str": "str"}, + "friendlyName": "str", + "frontdoorId": "str", + "frontendEndpoints": [ + { + "customHttpsConfiguration": { + "certificateSource": "str", + "minimumTlsVersion": "str", + "protocolType": "str", + "certificateType": "str", + "secretName": "str", + "secretVersion": "str", + "vault": {"id": "str"}, + }, + "customHttpsProvisioningState": "str", + "customHttpsProvisioningSubstate": "str", + "hostName": "str", + "id": "str", + "name": "str", + "resourceState": "str", + "sessionAffinityEnabledState": "str", + "sessionAffinityTtlSeconds": 0, + "type": "str", + "webApplicationFirewallPolicyLink": {"id": "str"}, + } + ], + "healthProbeSettings": [ + { + "enabledState": "str", + "healthProbeMethod": "HEAD", + "id": "str", + "intervalInSeconds": 0, + "name": "str", + "path": "str", + "protocol": "str", + "resourceState": "str", + "type": "str", + } + ], + "id": "str", + "loadBalancingSettings": [ + { + "additionalLatencyMilliseconds": 0, + "id": "str", + "name": "str", + "resourceState": "str", + "sampleSize": 0, + "successfulSamplesRequired": 0, + "type": "str", + } + ], + "location": "str", + "name": "str", + "provisioningState": "str", + "resourceState": "str", + "routingRules": [ + { + "acceptedProtocols": ["str"], + "enabledState": "str", + "frontendEndpoints": [{"id": "str"}], + "id": "str", + "name": "str", + "patternsToMatch": ["str"], + "resourceState": "str", + "routeConfiguration": "route_configuration", + "rulesEngine": {"id": "str"}, + "type": "str", + "webApplicationFirewallPolicyLink": {"id": "str"}, + } + ], + "rulesEngines": [ + { + "id": "str", + "name": "str", + "resourceState": "str", + "rules": [ + { + "action": { + "requestHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "responseHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "routeConfigurationOverride": "route_configuration", + }, + "name": "str", + "priority": 0, + "matchConditions": [ + { + "rulesEngineMatchValue": ["str"], + "rulesEngineMatchVariable": "str", + "rulesEngineOperator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "matchProcessingBehavior": "str", + } + ], + "type": "str", + } + ], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_front_doors_begin_delete(self, resource_group): + response = await ( + await self.client.front_doors.begin_delete( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + ).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_front_doors_validate_custom_domain(self, resource_group): + response = await self.client.front_doors.validate_custom_domain( + resource_group_name=resource_group.name, + front_door_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_operations.py new file mode 100644 index 000000000000..efb2c40ce105 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontendEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_frontend_endpoints_list_by_front_door(self, resource_group): + response = self.client.frontend_endpoints.list_by_front_door( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_frontend_endpoints_get(self, resource_group): + response = self.client.frontend_endpoints.get( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_frontend_endpoints_begin_enable_https(self, resource_group): + response = self.client.frontend_endpoints.begin_enable_https( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + custom_https_configuration={ + "certificateSource": "str", + "minimumTlsVersion": "str", + "protocolType": "str", + "certificateType": "str", + "secretName": "str", + "secretVersion": "str", + "vault": {"id": "str"}, + }, + api_version="2021-06-01", + ).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_frontend_endpoints_begin_disable_https(self, resource_group): + response = self.client.frontend_endpoints.begin_disable_https( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_operations_async.py new file mode 100644 index 000000000000..5bf8391a1660 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_frontend_endpoints_operations_async.py @@ -0,0 +1,84 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementFrontendEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_frontend_endpoints_list_by_front_door(self, resource_group): + response = self.client.frontend_endpoints.list_by_front_door( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + 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_frontend_endpoints_get(self, resource_group): + response = await self.client.frontend_endpoints.get( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_frontend_endpoints_begin_enable_https(self, resource_group): + response = await ( + await self.client.frontend_endpoints.begin_enable_https( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + custom_https_configuration={ + "certificateSource": "str", + "minimumTlsVersion": "str", + "protocolType": "str", + "certificateType": "str", + "secretName": "str", + "secretVersion": "str", + "vault": {"id": "str"}, + }, + api_version="2021-06-01", + ) + ).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_frontend_endpoints_begin_disable_https(self, resource_group): + response = await ( + await self.client.frontend_endpoints.begin_disable_https( + resource_group_name=resource_group.name, + front_door_name="str", + frontend_endpoint_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_operations.py new file mode 100644 index 000000000000..13d12a21b09e --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementManagedRuleSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_rule_sets_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2025-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_operations_async.py new file mode 100644 index 000000000000..a4aeb4f465c2 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_managed_rule_sets_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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementManagedRuleSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_rule_sets_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2025-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations.py new file mode 100644 index 000000000000..8f497a1802b8 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations.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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementNetworkExperimentProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_experiment_profiles_list(self, resource_group): + response = self.client.network_experiment_profiles.list( + api_version="2019-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_experiment_profiles_list_by_resource_group(self, resource_group): + response = self.client.network_experiment_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_experiment_profiles_get(self, resource_group): + response = self.client.network_experiment_profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_network_experiment_profiles_begin_create_or_update(self, resource_group): + response = self.client.network_experiment_profiles.begin_create_or_update( + profile_name="str", + resource_group_name=resource_group.name, + parameters={ + "enabledState": "str", + "etag": "str", + "id": "str", + "location": "str", + "name": "str", + "resourceState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-11-01", + ).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_network_experiment_profiles_begin_update(self, resource_group): + response = self.client.network_experiment_profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + parameters={"enabledState": "str", "tags": {"str": "str"}}, + api_version="2019-11-01", + ).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_network_experiment_profiles_begin_delete(self, resource_group): + response = self.client.network_experiment_profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations_async.py new file mode 100644 index 000000000000..796f45158c76 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_network_experiment_profiles_operations_async.py @@ -0,0 +1,106 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementNetworkExperimentProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_network_experiment_profiles_list(self, resource_group): + response = self.client.network_experiment_profiles.list( + api_version="2019-11-01", + ) + 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_network_experiment_profiles_list_by_resource_group(self, resource_group): + response = self.client.network_experiment_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-11-01", + ) + 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_network_experiment_profiles_get(self, resource_group): + response = await self.client.network_experiment_profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_network_experiment_profiles_begin_create_or_update(self, resource_group): + response = await ( + await self.client.network_experiment_profiles.begin_create_or_update( + profile_name="str", + resource_group_name=resource_group.name, + parameters={ + "enabledState": "str", + "etag": "str", + "id": "str", + "location": "str", + "name": "str", + "resourceState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-11-01", + ) + ).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_network_experiment_profiles_begin_update(self, resource_group): + response = await ( + await self.client.network_experiment_profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + parameters={"enabledState": "str", "tags": {"str": "str"}}, + api_version="2019-11-01", + ) + ).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_network_experiment_profiles_begin_delete(self, resource_group): + response = await ( + await self.client.network_experiment_profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations.py new file mode 100644 index 000000000000..bba679678b8c --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations.py @@ -0,0 +1,173 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2025-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_list_by_subscription(self, resource_group): + response = self.client.policies.list_by_subscription( + api_version="2025-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_get(self, resource_group): + response = self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policies_begin_create_or_update(self, resource_group): + response = self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + parameters={ + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "priority": 0, + "ruleType": "str", + "enabledState": "str", + "groupBy": [{"variableName": "str"}], + "name": "str", + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + } + ] + }, + "etag": "str", + "frontendEndpointLinks": [{"id": "str"}], + "id": "str", + "location": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "exclusions": [{"matchVariable": "str", "selector": "str", "selectorMatchOperator": "str"}], + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "exclusions": [ + {"matchVariable": "str", "selector": "str", "selectorMatchOperator": "str"} + ], + "rules": [ + { + "ruleId": "str", + "action": "str", + "enabledState": "str", + "exclusions": [ + { + "matchVariable": "str", + "selector": "str", + "selectorMatchOperator": "str", + } + ], + } + ], + } + ], + "ruleSetAction": "str", + } + ] + }, + "name": "str", + "policySettings": { + "captchaExpirationInMinutes": 0, + "customBlockResponseBody": "str", + "customBlockResponseStatusCode": 0, + "enabledState": "str", + "javascriptChallengeExpirationInMinutes": 0, + "mode": "str", + "redirectUrl": "str", + "requestBodyCheck": "str", + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "provisioningState": "str", + "resourceState": "str", + "routingRuleLinks": [{"id": "str"}], + "securityPolicyLinks": [{"id": "str"}], + "sku": {"name": "str"}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-05-01", + ).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_policies_begin_update(self, resource_group): + response = self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2025-05-01", + ).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_policies_begin_delete(self, resource_group): + response = self.client.policies.begin_delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations_async.py new file mode 100644 index 000000000000..e5a6ed88c755 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_policies_operations_async.py @@ -0,0 +1,182 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policies_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2025-05-01", + ) + 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_policies_list_by_subscription(self, resource_group): + response = self.client.policies.list_by_subscription( + api_version="2025-05-01", + ) + 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_policies_get(self, resource_group): + response = await self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policies_begin_create_or_update(self, resource_group): + response = await ( + await self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + parameters={ + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "priority": 0, + "ruleType": "str", + "enabledState": "str", + "groupBy": [{"variableName": "str"}], + "name": "str", + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + } + ] + }, + "etag": "str", + "frontendEndpointLinks": [{"id": "str"}], + "id": "str", + "location": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "exclusions": [ + {"matchVariable": "str", "selector": "str", "selectorMatchOperator": "str"} + ], + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "exclusions": [ + {"matchVariable": "str", "selector": "str", "selectorMatchOperator": "str"} + ], + "rules": [ + { + "ruleId": "str", + "action": "str", + "enabledState": "str", + "exclusions": [ + { + "matchVariable": "str", + "selector": "str", + "selectorMatchOperator": "str", + } + ], + } + ], + } + ], + "ruleSetAction": "str", + } + ] + }, + "name": "str", + "policySettings": { + "captchaExpirationInMinutes": 0, + "customBlockResponseBody": "str", + "customBlockResponseStatusCode": 0, + "enabledState": "str", + "javascriptChallengeExpirationInMinutes": 0, + "mode": "str", + "redirectUrl": "str", + "requestBodyCheck": "str", + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "provisioningState": "str", + "resourceState": "str", + "routingRuleLinks": [{"id": "str"}], + "securityPolicyLinks": [{"id": "str"}], + "sku": {"name": "str"}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2025-05-01", + ) + ).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_policies_begin_update(self, resource_group): + response = await ( + await self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2025-05-01", + ) + ).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_policies_begin_delete(self, resource_group): + response = await ( + await self.client.policies.begin_delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2025-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations.py new file mode 100644 index 000000000000..283984a02ce9 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations.py @@ -0,0 +1,31 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementPreconfiguredEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_preconfigured_endpoints_list(self, resource_group): + response = self.client.preconfigured_endpoints.list( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations_async.py new file mode 100644 index 000000000000..d9d5262d35ab --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_preconfigured_endpoints_operations_async.py @@ -0,0 +1,32 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementPreconfiguredEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_preconfigured_endpoints_list(self, resource_group): + response = self.client.preconfigured_endpoints.list( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2019-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations.py new file mode 100644 index 000000000000..e56abea859fc --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations.py @@ -0,0 +1,50 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementReportsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_reports_get_latency_scorecards(self, resource_group): + response = self.client.reports.get_latency_scorecards( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + aggregation_interval="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_reports_get_timeseries(self, resource_group): + response = self.client.reports.get_timeseries( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + start_date_time_utc="2020-02-20 00:00:00", + end_date_time_utc="2020-02-20 00:00:00", + aggregation_interval="str", + timeseries_type="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations_async.py new file mode 100644 index 000000000000..2c5cafc929a9 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_reports_operations_async.py @@ -0,0 +1,51 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementReportsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_reports_get_latency_scorecards(self, resource_group): + response = await self.client.reports.get_latency_scorecards( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + aggregation_interval="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_reports_get_timeseries(self, resource_group): + response = await self.client.reports.get_timeseries( + resource_group_name=resource_group.name, + profile_name="str", + experiment_name="str", + start_date_time_utc="2020-02-20 00:00:00", + end_date_time_utc="2020-02-20 00:00:00", + aggregation_interval="str", + timeseries_type="str", + api_version="2019-11-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations.py new file mode 100644 index 000000000000..e4c7ae503f67 --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations.py @@ -0,0 +1,98 @@ +# 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.frontdoor import FrontDoorManagementClient + +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 TestFrontDoorManagementRulesEnginesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_engines_list_by_front_door(self, resource_group): + response = self.client.rules_engines.list_by_front_door( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_engines_get(self, resource_group): + response = self.client.rules_engines.get( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rules_engines_begin_create_or_update(self, resource_group): + response = self.client.rules_engines.begin_create_or_update( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + rules_engine_parameters={ + "id": "str", + "name": "str", + "resourceState": "str", + "rules": [ + { + "action": { + "requestHeaderActions": [{"headerActionType": "str", "headerName": "str", "value": "str"}], + "responseHeaderActions": [{"headerActionType": "str", "headerName": "str", "value": "str"}], + "routeConfigurationOverride": "route_configuration", + }, + "name": "str", + "priority": 0, + "matchConditions": [ + { + "rulesEngineMatchValue": ["str"], + "rulesEngineMatchVariable": "str", + "rulesEngineOperator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "matchProcessingBehavior": "str", + } + ], + "type": "str", + }, + api_version="2021-06-01", + ).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_rules_engines_begin_delete(self, resource_group): + response = self.client.rules_engines.begin_delete( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations_async.py b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations_async.py new file mode 100644 index 000000000000..1f45cb6f1c2d --- /dev/null +++ b/sdk/network/azure-mgmt-frontdoor/generated_tests/test_front_door_management_rules_engines_operations_async.py @@ -0,0 +1,107 @@ +# 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.frontdoor.aio import FrontDoorManagementClient + +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 TestFrontDoorManagementRulesEnginesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(FrontDoorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rules_engines_list_by_front_door(self, resource_group): + response = self.client.rules_engines.list_by_front_door( + resource_group_name=resource_group.name, + front_door_name="str", + api_version="2021-06-01", + ) + 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_rules_engines_get(self, resource_group): + response = await self.client.rules_engines.get( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rules_engines_begin_create_or_update(self, resource_group): + response = await ( + await self.client.rules_engines.begin_create_or_update( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + rules_engine_parameters={ + "id": "str", + "name": "str", + "resourceState": "str", + "rules": [ + { + "action": { + "requestHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "responseHeaderActions": [ + {"headerActionType": "str", "headerName": "str", "value": "str"} + ], + "routeConfigurationOverride": "route_configuration", + }, + "name": "str", + "priority": 0, + "matchConditions": [ + { + "rulesEngineMatchValue": ["str"], + "rulesEngineMatchVariable": "str", + "rulesEngineOperator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "matchProcessingBehavior": "str", + } + ], + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_rules_engines_begin_delete(self, resource_group): + response = await ( + await self.client.rules_engines.begin_delete( + resource_group_name=resource_group.name, + front_door_name="str", + rules_engine_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-frontdoor/setup.py b/sdk/network/azure-mgmt-frontdoor/setup.py index aed570f34b33..b68cb33dab4a 100644 --- a/sdk/network/azure-mgmt-frontdoor/setup.py +++ b/sdk/network/azure-mgmt-frontdoor/setup.py @@ -53,7 +53,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -75,8 +74,9 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.8", + python_requires=">=3.9", )