From 4ecc891b0a1274271d5570034977e9c62693dc54 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 25 Sep 2024 02:42:59 +0000 Subject: [PATCH 1/4] code and test --- sdk/network/azure-mgmt-dns/CHANGELOG.md | 6 + sdk/network/azure-mgmt-dns/README.md | 7 +- sdk/network/azure-mgmt-dns/_meta.json | 16 +- .../azure/mgmt/dns/_configuration.py | 5 +- .../azure/mgmt/dns/_dns_management_client.py | 23 +- .../azure/mgmt/dns/_serialization.py | 122 +++++----- .../azure-mgmt-dns/azure/mgmt/dns/_version.py | 2 +- .../azure/mgmt/dns/aio/_configuration.py | 5 +- .../mgmt/dns/aio/_dns_management_client.py | 23 +- .../mgmt/dns/v2016_04_01/_configuration.py | 7 +- .../dns/v2016_04_01/_dns_management_client.py | 29 ++- .../azure/mgmt/dns/v2016_04_01/_metadata.json | 10 +- .../azure/mgmt/dns/v2016_04_01/_vendor.py | 30 --- .../azure/mgmt/dns/v2016_04_01/_version.py | 2 +- .../dns/v2016_04_01/aio/_configuration.py | 7 +- .../v2016_04_01/aio/_dns_management_client.py | 31 ++- .../aio/operations/_record_sets_operations.py | 179 +++++--------- .../aio/operations/_zones_operations.py | 182 ++++++-------- .../dns/v2016_04_01/models/_models_py3.py | 10 +- .../operations/_record_sets_operations.py | 191 ++++++--------- .../operations/_zones_operations.py | 192 ++++++--------- .../dns/v2018_03_01_preview/_configuration.py | 7 +- .../_dns_management_client.py | 29 ++- .../dns/v2018_03_01_preview/_metadata.json | 10 +- .../mgmt/dns/v2018_03_01_preview/_vendor.py | 30 --- .../mgmt/dns/v2018_03_01_preview/_version.py | 2 +- .../v2018_03_01_preview/aio/_configuration.py | 7 +- .../aio/_dns_management_client.py | 31 ++- .../aio/operations/_record_sets_operations.py | 207 ++++++---------- .../aio/operations/_zones_operations.py | 214 +++++++---------- .../v2018_03_01_preview/models/_models_py3.py | 10 +- .../operations/_record_sets_operations.py | 221 ++++++----------- .../operations/_zones_operations.py | 226 +++++++----------- .../mgmt/dns/v2018_05_01/_configuration.py | 7 +- .../dns/v2018_05_01/_dns_management_client.py | 29 ++- .../azure/mgmt/dns/v2018_05_01/_metadata.json | 10 +- .../azure/mgmt/dns/v2018_05_01/_vendor.py | 30 --- .../azure/mgmt/dns/v2018_05_01/_version.py | 2 +- .../dns/v2018_05_01/aio/_configuration.py | 7 +- .../v2018_05_01/aio/_dns_management_client.py | 31 ++- .../_dns_resource_reference_operations.py | 49 ++-- .../aio/operations/_record_sets_operations.py | 207 ++++++---------- .../aio/operations/_zones_operations.py | 214 +++++++---------- .../dns/v2018_05_01/models/_models_py3.py | 4 +- .../_dns_resource_reference_operations.py | 51 ++-- .../operations/_record_sets_operations.py | 221 ++++++----------- .../operations/_zones_operations.py | 226 +++++++----------- .../dns/v2023_07_01_preview/_configuration.py | 7 +- .../_dns_management_client.py | 29 ++- .../dns/v2023_07_01_preview/_metadata.json | 10 +- .../mgmt/dns/v2023_07_01_preview/_vendor.py | 30 --- .../mgmt/dns/v2023_07_01_preview/_version.py | 2 +- .../v2023_07_01_preview/aio/_configuration.py | 7 +- .../aio/_dns_management_client.py | 31 ++- .../_dns_resource_reference_operations.py | 50 ++-- .../operations/_dnssec_configs_operations.py | 170 ++++++------- .../aio/operations/_record_sets_operations.py | 207 ++++++---------- .../aio/operations/_zones_operations.py | 214 +++++++---------- .../v2023_07_01_preview/models/_models_py3.py | 13 +- .../_dns_resource_reference_operations.py | 52 ++-- .../operations/_dnssec_configs_operations.py | 178 ++++++-------- .../operations/_record_sets_operations.py | 221 ++++++----------- .../operations/_zones_operations.py | 226 +++++++----------- .../create_or_update_aaaa_recordset.py | 1 + .../create_or_update_arecordset.py | 1 + .../create_or_update_arecordset_alias.py | 1 + .../create_or_update_caa_recordset.py | 1 + .../create_or_update_cname_recordset.py | 1 + .../create_or_update_mx_recordset.py | 1 + .../create_or_update_ns_recordset.py | 1 + .../create_or_update_ptr_recordset.py | 1 + .../create_or_update_soa_recordset.py | 1 + .../create_or_update_srv_recordset.py | 1 + .../create_or_update_txt_recordset.py | 1 + .../create_or_update_zone.py | 1 + .../delete_aaaa_recordset.py | 1 + .../generated_samples/delete_arecordset.py | 1 + .../generated_samples/delete_caa_recordset.py | 1 + .../generated_samples/delete_ptr_recordset.py | 1 + .../generated_samples/delete_srv_recordset.py | 1 + .../generated_samples/delete_txt_recordset.py | 1 + .../generated_samples/delete_zone.py | 1 + .../generated_samples/get_aaaa_recordset.py | 1 + .../generated_samples/get_arecordset.py | 1 + .../generated_samples/get_caa_recordset.py | 1 + .../generated_samples/get_cname_recordset.py | 1 + .../get_dns_resource_reference.py | 1 + .../generated_samples/get_mx_recordset.py | 1 + .../generated_samples/get_ns_recordset.py | 1 + .../generated_samples/get_ptr_recordset.py | 1 + .../generated_samples/get_soa_recordset.py | 1 + .../generated_samples/get_srv_recordset.py | 1 + .../generated_samples/get_txt_recordset.py | 1 + .../generated_samples/get_zone.py | 1 + .../generated_samples/list_aaaa_recordset.py | 1 + .../generated_samples/list_arecordset.py | 1 + .../generated_samples/list_caa_recordset.py | 1 + .../generated_samples/list_cname_recordset.py | 1 + .../generated_samples/list_mx_recordset.py | 1 + .../generated_samples/list_ns_recordset.py | 1 + .../generated_samples/list_ptr_recordset.py | 1 + .../list_record_sets_by_zone.py | 3 +- .../generated_samples/list_soa_recordset.py | 1 + .../generated_samples/list_srv_recordset.py | 1 + .../generated_samples/list_txt_recordset.py | 1 + .../list_zones_by_resource_group.py | 1 + .../list_zones_by_subscription.py | 1 + .../generated_samples/patch_aaaa_recordset.py | 1 + .../generated_samples/patch_arecordset.py | 1 + .../generated_samples/patch_caa_recordset.py | 1 + .../patch_cname_recordset.py | 1 + .../generated_samples/patch_mx_recordset.py | 1 + .../generated_samples/patch_ns_recordset.py | 1 + .../generated_samples/patch_ptr_recordset.py | 1 + .../generated_samples/patch_soa_recordset.py | 1 + .../generated_samples/patch_srv_recordset.py | 1 + .../generated_samples/patch_txt_recordset.py | 1 + .../generated_samples/patch_zone.py | 1 + .../generated_tests/conftest.py | 35 +++ ...ement_dns_resource_reference_operations.py | 30 +++ ...dns_resource_reference_operations_async.py | 31 +++ ...t_dns_management_record_sets_operations.py | 170 +++++++++++++ ...management_record_sets_operations_async.py | 171 +++++++++++++ .../test_dns_management_zones_operations.py | 104 ++++++++ ...t_dns_management_zones_operations_async.py | 107 +++++++++ sdk/network/azure-mgmt-dns/setup.py | 12 +- 126 files changed, 2577 insertions(+), 2748 deletions(-) delete mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py delete mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py delete mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py delete mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/conftest.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_operations.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_operations_async.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations_async.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations.py create mode 100644 sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations_async.py diff --git a/sdk/network/azure-mgmt-dns/CHANGELOG.md b/sdk/network/azure-mgmt-dns/CHANGELOG.md index 3efd31cab4e3..63f318e09b94 100644 --- a/sdk/network/azure-mgmt-dns/CHANGELOG.md +++ b/sdk/network/azure-mgmt-dns/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 8.2.0 (2024-10-21) + +### Features Added + + - Model RecordSet has a new parameter traffic_management_profile + ## 8.1.0 (2023-06-14) ### Features Added diff --git a/sdk/network/azure-mgmt-dns/README.md b/sdk/network/azure-mgmt-dns/README.md index 334a20b07cbc..bc4308b6b139 100644 --- a/sdk/network/azure-mgmt-dns/README.md +++ b/sdk/network/azure-mgmt-dns/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure DNS Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. 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.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-dns%2FREADME.png) diff --git a/sdk/network/azure-mgmt-dns/_meta.json b/sdk/network/azure-mgmt-dns/_meta.json index 4ba485e110ef..6a46a71ec1c6 100644 --- a/sdk/network/azure-mgmt-dns/_meta.json +++ b/sdk/network/azure-mgmt-dns/_meta.json @@ -1,11 +1,15 @@ { - "commit": "e2b5f9323c4214408969a6e953b4075cfdc693b6", + "commit": "7189fb57f69468c56df76f9a4d68dd9ff04ab100", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.6.0", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/dns/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.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/dns/resource-manager/readme.md" + "autorest_command": "autorest specification/dns/resource-manager/readme.md --generate-sample=True --generate-test=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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/dns/resource-manager/readme.md", + "package-2023-07-preview": "2024-01-03 09:33:30 -0800 389c6c7476ec7c6585b002b44a9dacfb5c88b71a Microsoft.Network/preview/2023-07-01-preview/dns.json", + "package-2018-05": "2020-11-17 18:50:08 -0800 b47a32169e59378d8005aabb5358e3f4ddf10766 Microsoft.Network/stable/2018-05-01/dns.json", + "package-2018-03-preview": "2020-11-17 18:50:08 -0800 b47a32169e59378d8005aabb5358e3f4ddf10766 Microsoft.Network/preview/2018-03-01-preview/dns.json", + "package-2016-04": "2021-01-26 16:35:03 -0800 866a7d07ee081198c77bf4949e2a6ce366e103fa Microsoft.Network/stable/2016-04-01/dns.json" } \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py index afd57be6470e..3da2405a3de6 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration: """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-dns/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py index 52e0eb799a99..514818e49578 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -74,7 +77,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(DnsManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py index e3cc6ce6ed6f..59f1fcf71bc9 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + 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 @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: 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__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ 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) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -392,7 +387,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -417,7 +412,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -447,7 +442,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -547,7 +542,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,7 +558,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -651,7 +646,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,12 +659,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -711,7 +707,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -731,6 +727,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -743,7 +740,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :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 """ @@ -751,10 +750,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get('skip_quote', False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -805,7 +802,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -825,7 +822,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -893,6 +890,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): 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 """ if isinstance(data, str): @@ -905,9 +904,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +960,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -985,7 +995,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1162,10 +1172,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1201,7 +1211,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1222,7 +1231,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1363,7 +1371,7 @@ class Deserializer(object): 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}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]]=None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1436,12 +1444,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1473,7 +1481,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1507,14 +1515,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1570,7 +1578,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1644,7 +1652,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1692,7 +1700,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1749,7 +1757,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1800,7 +1808,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1854,10 +1861,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1885,7 +1892,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1902,7 +1909,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1937,7 +1944,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1974,7 +1981,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1990,9 +1997,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py index 9d6b829337f5..2fb918ea8c81 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "8.2.0" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py index 8a53ee0b3c6d..2621a2f2502d 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py @@ -10,7 +10,6 @@ # -------------------------------------------------------------------------- from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -20,7 +19,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration: """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -42,12 +41,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-dns/{}'.format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py index b5c8432e3ec3..7925c2f0bea8 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py @@ -10,8 +10,11 @@ # -------------------------------------------------------------------------- from typing import Any, Optional, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -74,7 +77,25 @@ def __init__( if api_version: kwargs.setdefault('api_version', api_version) self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(DnsManagementClient, self).__init__( api_version=api_version, profile=profile diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py index 4e75d86272e2..b21a767e800c 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py index c1601dffbac3..f9c42b56e8a7 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -63,7 +84,7 @@ def __init__( ) self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize, "2016-04-01") - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,12 +104,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DnsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json index 98d2f164abbc..729ddded8d49 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py index 920456322fa1..d5f3055d6eb4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "8.2.0" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py index c8dab4003166..0868596e9bd4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2016-04-01") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py index 213cb73b5529..967f2c52755b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -63,7 +84,9 @@ def __init__( ) self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize, "2016-04-01") - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -83,12 +106,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DnsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py index ee504729a417..60693401fd92 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._record_sets_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +100,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -110,7 +112,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -130,7 +132,7 @@ async def update( "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -138,7 +140,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -151,7 +152,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -169,21 +170,17 @@ async def update( "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,7 +203,7 @@ async def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -217,16 +214,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,16 +230,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -286,7 +277,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -299,7 +289,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -321,7 +311,7 @@ async def create_or_update( "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -332,7 +322,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -345,7 +334,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -365,8 +354,8 @@ async def create_or_update( "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -374,15 +363,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,7 +390,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -417,16 +402,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,21 +418,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -478,12 +453,11 @@ async def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,7 +471,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -505,16 +479,14 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,11 +496,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -552,12 +520,11 @@ async def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -571,23 +538,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,16 +561,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -634,7 +595,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -645,7 +605,7 @@ def list_by_type( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,7 +616,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -664,12 +624,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -680,14 +638,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -697,11 +654,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -713,10 +670,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -740,7 +693,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -751,7 +703,7 @@ def list_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -762,19 +714,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -785,14 +735,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -802,11 +751,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -817,7 +766,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py index 261c5cf99e76..e358d31fba68 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._zones_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +40,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +99,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -120,7 +124,7 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -131,7 +135,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -142,7 +145,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -155,8 +158,8 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -164,15 +167,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,7 +194,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -205,16 +204,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,25 +220,17 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - async def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.ZoneDeleteResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,44 +242,41 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) - cls: ClsType[Optional[_models.ZoneDeleteResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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 = None - if response.status_code == 200: - deserialized = self._deserialize("ZoneDeleteResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -308,14 +294,6 @@ async def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ZoneDeleteResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] @@ -340,12 +318,13 @@ 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): - deserialized = self._deserialize("ZoneDeleteResult", pipeline_response) + deserialized = self._deserialize("ZoneDeleteResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -355,17 +334,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ZoneDeleteResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return AsyncLROPoller[_models.ZoneDeleteResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -376,12 +353,11 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,21 +371,19 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,16 +392,12 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -441,7 +411,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -452,7 +421,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,17 +432,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -484,14 +451,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -501,11 +467,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -517,10 +483,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -528,7 +490,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -539,7 +500,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -550,16 +511,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -570,14 +529,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -587,11 +545,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,5 +560,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py index c77a75b42bc6..338c5ae79dcd 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py @@ -381,7 +381,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -551,10 +551,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -619,10 +619,10 @@ class Zone(TrackedResource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py index 60d024e59fa6..cdcff6e85244 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +124,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +174,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,7 +218,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -256,7 +259,7 @@ def build_list_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -299,7 +302,7 @@ def build_list_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -369,7 +372,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -382,7 +384,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -402,7 +404,7 @@ def update( "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -410,7 +412,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -423,7 +424,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -441,21 +442,17 @@ def update( "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,7 +475,7 @@ def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -489,16 +486,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,16 +502,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -558,7 +549,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -571,7 +561,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -593,7 +583,7 @@ def create_or_update( "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -604,7 +594,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -617,7 +606,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -637,8 +626,8 @@ def create_or_update( "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -646,15 +635,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,7 +662,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -689,16 +674,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -707,21 +690,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -750,12 +725,11 @@ def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -769,7 +743,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -777,16 +751,14 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,11 +768,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -824,12 +792,11 @@ def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,23 +810,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -868,16 +833,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -906,7 +867,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -917,7 +877,7 @@ def list_by_type( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -928,7 +888,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -936,12 +896,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -952,14 +910,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -969,11 +926,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,10 +942,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -1012,7 +965,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1023,7 +975,7 @@ def list_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1034,19 +986,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1057,14 +1007,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1074,11 +1023,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1089,7 +1038,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py index 840be18aa539..e1fffbfaf77b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +73,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +112,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +145,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +177,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -198,7 +203,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -262,7 +267,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -273,7 +277,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -288,7 +292,7 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -299,7 +303,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -310,7 +313,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -323,8 +326,8 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -332,15 +335,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +362,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -373,16 +372,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,25 +388,17 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.ZoneDeleteResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,44 +410,41 @@ def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) - cls: ClsType[Optional[_models.ZoneDeleteResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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 = None - if response.status_code == 200: - deserialized = self._deserialize("ZoneDeleteResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -476,14 +462,6 @@ def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ZoneDeleteResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] @@ -508,12 +486,13 @@ 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): - deserialized = self._deserialize("ZoneDeleteResult", pipeline_response) + deserialized = self._deserialize("ZoneDeleteResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -523,17 +502,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ZoneDeleteResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return LROPoller[_models.ZoneDeleteResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -544,12 +521,11 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -563,21 +539,19 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -586,16 +560,12 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -609,7 +579,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -620,7 +589,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -631,17 +600,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -652,14 +619,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -669,11 +635,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -685,10 +651,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -696,7 +658,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -707,7 +668,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -718,16 +679,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -738,14 +697,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -755,11 +713,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -770,5 +728,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py index 53a75711927c..0ee3ba04e90b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py index a81ec8a40bd5..d3c8c270da50 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -65,7 +86,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -85,12 +106,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DnsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json index 00de73bf9064..c1d0f093ecc1 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py index 920456322fa1..d5f3055d6eb4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "8.2.0" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py index 178fce2cf59c..7db23a1f5b77 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py index 9604b4783e23..aa8dfb1337e0 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -52,7 +55,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -65,7 +86,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-03-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -85,12 +108,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DnsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py index 7d860f3dcd43..d525d769d56c 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._record_sets_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -98,7 +101,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -111,7 +113,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -131,7 +133,7 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -139,7 +141,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -152,7 +153,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -170,21 +171,17 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +206,7 @@ async def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -220,16 +217,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -238,16 +233,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -289,7 +280,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +292,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -324,7 +314,7 @@ async def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -335,7 +325,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +337,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -368,8 +357,8 @@ async def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -377,15 +366,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +395,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -422,16 +407,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -440,21 +423,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -483,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,7 +478,7 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -512,16 +486,14 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,11 +503,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -559,12 +527,11 @@ async def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,23 +547,21 @@ async def get( ) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -605,16 +570,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -643,7 +604,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] @@ -657,7 +617,7 @@ def list_by_type( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,7 +628,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -676,12 +636,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -692,14 +650,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -709,11 +666,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,10 +682,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -752,7 +705,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] @@ -766,7 +718,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -777,19 +729,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -800,14 +750,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -817,11 +766,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,10 +782,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -860,7 +805,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] @@ -874,7 +818,7 @@ def list_all_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -885,19 +829,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -908,14 +850,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -925,11 +866,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -940,7 +881,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py index a2e68b8c6df8..5644b1d9eefb 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._zones_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +100,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +110,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -121,7 +125,7 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -132,7 +136,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -143,7 +146,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -156,8 +159,8 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -165,15 +168,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,7 +197,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -208,16 +207,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,25 +223,17 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,38 +247,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -307,14 +299,6 @@ async def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -330,7 +314,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, zone_name=zone_name, if_match=if_match, @@ -340,11 +324,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -353,17 +338,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -374,12 +355,11 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,21 +375,19 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> ) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,16 +396,12 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload async def update( @@ -456,7 +430,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -467,7 +440,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -481,7 +454,7 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -489,7 +462,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -500,7 +472,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -512,21 +484,17 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,7 +519,7 @@ async def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -560,16 +528,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -578,16 +544,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -601,7 +563,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] @@ -615,7 +576,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -626,17 +587,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -647,14 +606,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -664,11 +622,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -680,10 +638,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -691,7 +645,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] @@ -705,7 +658,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -716,16 +669,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -736,14 +687,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -753,11 +703,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -768,5 +718,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py index d084c604b892..90f8bb6a739a 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py @@ -418,7 +418,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -588,10 +588,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -656,10 +656,10 @@ class Zone(TrackedResource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py index 9da5acb239ee..7221b1078d2c 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +124,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +174,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,7 +218,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -256,7 +259,7 @@ def build_list_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -299,7 +302,7 @@ def build_list_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -342,7 +345,7 @@ def build_list_all_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -412,7 +415,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +427,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -445,7 +447,7 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -453,7 +455,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -466,7 +467,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -484,21 +485,17 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,7 +520,7 @@ def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -534,16 +531,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,16 +547,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -603,7 +594,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -616,7 +606,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -638,7 +628,7 @@ def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -649,7 +639,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -662,7 +651,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -682,8 +671,8 @@ def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -691,15 +680,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -724,7 +709,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -736,16 +721,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -754,21 +737,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -797,12 +772,11 @@ def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -818,7 +792,7 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -826,16 +800,14 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -845,11 +817,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -873,12 +841,11 @@ def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -894,23 +861,21 @@ def get( ) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -919,16 +884,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -957,7 +918,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -970,7 +930,7 @@ def list_by_type( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -981,7 +941,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -989,12 +949,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1005,14 +963,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1022,11 +979,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1038,10 +995,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -1065,7 +1018,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1078,7 +1030,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1089,19 +1041,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1112,14 +1062,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1129,11 +1078,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1145,10 +1094,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -1172,7 +1117,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1185,7 +1129,7 @@ def list_all_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1196,19 +1140,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1219,14 +1161,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1236,11 +1177,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,7 +1192,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py index 430440d91182..e50c4af0ccaa 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +73,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +112,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +145,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,7 +179,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +215,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -236,7 +241,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -300,7 +305,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +315,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -326,7 +330,7 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -337,7 +341,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -361,8 +364,8 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -370,15 +373,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +402,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -413,16 +412,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -431,25 +428,17 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,38 +452,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2018-03-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -512,14 +504,6 @@ def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -535,7 +519,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, zone_name=zone_name, if_match=if_match, @@ -545,11 +529,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -558,17 +543,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -579,12 +560,11 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,21 +580,19 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model ) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -623,16 +601,12 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload def update( @@ -661,7 +635,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -672,7 +645,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -686,7 +659,7 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -694,7 +667,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -705,7 +677,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -717,21 +689,17 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -756,7 +724,7 @@ def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -765,16 +733,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -783,16 +749,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -806,7 +768,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -819,7 +780,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,17 +791,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -851,14 +810,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -868,11 +826,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -884,10 +842,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -895,7 +849,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -908,7 +861,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -919,16 +872,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -939,14 +890,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -956,11 +906,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -971,5 +921,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py index 3ff9c5f8aaba..892078296a8b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py index 8d6391656670..33cc3cfcc708 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -56,7 +59,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -70,7 +91,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-05-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,12 +111,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DnsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json index d6413dd44215..e8b400087b5a 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py index 920456322fa1..d5f3055d6eb4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "8.2.0" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py index f810803dcb0f..8c43d85999aa 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -36,7 +35,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2018-05-01") if credential is None: @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py index b7f013f241ac..334fc69c8804 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -56,7 +59,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -70,7 +91,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2018-05-01" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,12 +113,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DnsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py index 614dbc3105c1..22e1cf3911c0 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._dns_resource_reference_operations import build_get_by_target_resources_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,6 @@ async def get_by_target_resources( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -71,16 +73,15 @@ async def get_by_target_resources( @overload async def get_by_target_resources( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -88,22 +89,18 @@ async def get_by_target_resources( @distributed_trace_async async def get_by_target_resources( - self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **kwargs: Any + self, parameters: Union[_models.DnsResourceReferenceRequest, IO[bytes]], **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Is either a - DnsResourceReferenceRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DnsResourceReferenceRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest or IO[bytes] :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,22 +123,20 @@ async def get_by_target_resources( else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") - request = build_get_by_target_resources_request( + _request = build_get_by_target_resources_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_by_target_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,13 +145,9 @@ async def get_by_target_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_target_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py index 79326c47696c..56234dc34b47 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._record_sets_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,7 +100,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -110,7 +112,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -129,7 +131,7 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -137,7 +139,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -150,7 +151,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -167,21 +168,17 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,7 +201,7 @@ async def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -215,16 +212,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,16 +228,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -283,7 +274,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -296,7 +286,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -317,7 +307,7 @@ async def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -328,7 +318,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -341,7 +330,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -360,8 +349,8 @@ async def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -369,15 +358,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -400,7 +385,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -412,16 +397,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,21 +413,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -472,12 +447,11 @@ async def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -491,7 +465,7 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -499,16 +473,14 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -518,11 +490,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -545,12 +513,11 @@ async def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,23 +531,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -589,16 +554,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -626,7 +587,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -637,7 +597,7 @@ def list_by_type( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,7 +608,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -656,12 +616,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -672,14 +630,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -689,11 +646,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -705,10 +662,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -731,7 +684,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -742,7 +694,7 @@ def list_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -753,19 +705,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -776,14 +726,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -793,11 +742,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -809,10 +758,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -835,7 +780,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -846,7 +790,7 @@ def list_all_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,19 +801,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -880,14 +822,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -897,11 +838,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -912,7 +853,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py index 13012e4520ec..b8e2dc8523e4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._zones_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +99,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +109,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -119,7 +123,7 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -130,7 +134,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -141,7 +144,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -153,8 +156,8 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -162,15 +165,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,7 +192,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -203,16 +202,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,25 +218,17 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,38 +240,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -299,14 +291,6 @@ async def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -320,7 +304,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, zone_name=zone_name, if_match=if_match, @@ -330,11 +314,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -343,17 +328,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -363,12 +344,11 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -382,21 +362,19 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -405,16 +383,12 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload async def update( @@ -442,7 +416,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -453,7 +426,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -466,7 +439,7 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -474,7 +447,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -485,7 +457,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -496,21 +468,17 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -533,7 +501,7 @@ async def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -542,16 +510,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -560,16 +526,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -582,7 +544,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -593,7 +554,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -604,17 +565,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -625,14 +584,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -642,11 +600,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -658,10 +616,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -669,7 +623,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -680,7 +633,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,16 +644,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -711,14 +662,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -728,11 +678,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -743,5 +693,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py index 9946acc70051..bb9442c68ca0 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py @@ -512,7 +512,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -716,7 +716,7 @@ class Zone(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py index 5f184c4045bf..856306aafed0 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ 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, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_by_target_resources_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +98,6 @@ def get_by_target_resources( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,16 +105,15 @@ def get_by_target_resources( @overload def get_by_target_resources( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -120,22 +121,18 @@ def get_by_target_resources( @distributed_trace def get_by_target_resources( - self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **kwargs: Any + self, parameters: Union[_models.DnsResourceReferenceRequest, IO[bytes]], **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Is either a - DnsResourceReferenceRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DnsResourceReferenceRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest or IO[bytes] :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -158,22 +155,20 @@ def get_by_target_resources( else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") - request = build_get_by_target_resources_request( + _request = build_get_by_target_resources_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_by_target_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,13 +177,9 @@ def get_by_target_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_target_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py index fe95afafa08c..7232a6e75770 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +72,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +120,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,7 +168,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,7 +210,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -246,7 +249,7 @@ def build_list_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -287,7 +290,7 @@ def build_list_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -328,7 +331,7 @@ def build_list_all_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -397,7 +400,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +412,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -429,7 +431,7 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -437,7 +439,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -450,7 +451,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -467,21 +468,17 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,7 +501,7 @@ def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -515,16 +512,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -533,16 +528,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -583,7 +574,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -596,7 +586,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -617,7 +607,7 @@ def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -628,7 +618,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -641,7 +630,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -660,8 +649,8 @@ def create_or_update( "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -669,15 +658,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -700,7 +685,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -712,16 +697,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -730,21 +713,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -772,12 +747,11 @@ def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,7 +765,7 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -799,16 +773,14 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -818,11 +790,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -845,12 +813,11 @@ def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", and "TXT". Required. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -864,23 +831,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -889,16 +854,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -926,7 +887,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -937,7 +897,7 @@ def list_by_type( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -948,7 +908,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -956,12 +916,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -972,14 +930,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -989,11 +946,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1005,10 +962,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -1031,7 +984,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1042,7 +994,7 @@ def list_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1053,19 +1005,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1076,14 +1026,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1093,11 +1042,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1109,10 +1058,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -1135,7 +1080,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1146,7 +1090,7 @@ def list_all_by_dns_zone( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1157,19 +1101,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1180,14 +1122,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1197,11 +1138,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1212,7 +1153,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py index fcfce70e8cfb..5b6c0f5941ec 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +71,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +108,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +139,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,7 +171,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -200,7 +205,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -226,7 +231,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -289,7 +294,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -300,7 +304,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -314,7 +318,7 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -325,7 +329,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -336,7 +339,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -348,8 +351,8 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -357,15 +360,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -398,16 +397,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,25 +413,17 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,38 +435,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -494,14 +486,6 @@ def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +499,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, zone_name=zone_name, if_match=if_match, @@ -525,11 +509,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -538,17 +523,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -558,12 +539,11 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,21 +557,19 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,16 +578,12 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload def update( @@ -637,7 +611,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -648,7 +621,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -661,7 +634,7 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -669,7 +642,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -680,7 +652,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -691,21 +663,17 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -728,7 +696,7 @@ def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -737,16 +705,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -755,16 +721,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -777,7 +739,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -788,7 +749,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -799,17 +760,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -820,14 +779,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -837,11 +795,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,10 +811,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -864,7 +818,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -875,7 +828,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,16 +839,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -906,14 +857,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -923,11 +873,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -938,5 +888,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py index 319d99ef1d1f..15867643e04d 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py index 35c4dbced991..836ed00bb9f7 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from .._serialization import Deserializer, Serializer @@ -57,7 +60,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -76,7 +97,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2023-07-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -96,12 +117,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DnsManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json index 4448f4ce9b45..f836b9545a19 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": true, + "has_public_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { @@ -101,8 +101,8 @@ "credential_scopes": ["https://management.azure.com/.default"], "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "sync_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "dnssec_configs": "DnssecConfigsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py index 920456322fa1..d5f3055d6eb4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "8.2.0" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py index b7221faaef58..45362b825b12 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -35,7 +34,6 @@ class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-ma """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DnsManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-07-01-preview") if credential is None: @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dns/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.py index 27d21876b184..309c458b9de8 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from ..._serialization import Deserializer, Serializer @@ -58,7 +61,25 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + 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) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -77,7 +98,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize, "2023-07-01-preview" ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -97,12 +120,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DnsManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py index e4dbd1d9e840..edea9ce03414 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._dns_resource_reference_operations import build_get_by_target_resources_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,6 @@ async def get_by_target_resources( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -71,16 +73,15 @@ async def get_by_target_resources( @overload async def get_by_target_resources( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -88,22 +89,19 @@ async def get_by_target_resources( @distributed_trace_async async def get_by_target_resources( - self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **kwargs: Any + self, parameters: Union[_models.DnsResourceReferenceRequest, IO[bytes]], **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Is either a - DnsResourceReferenceRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DnsResourceReferenceRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest or + IO[bytes] :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,22 +126,20 @@ async def get_by_target_resources( else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") - request = build_get_by_target_resources_request( + _request = build_get_by_target_resources_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_by_target_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,13 +148,9 @@ async def get_by_target_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_target_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py index 04e0488249aa..d3f682cd89cb 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dnssec_configs_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +38,10 @@ build_list_by_dns_zone_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,8 +73,8 @@ async def _create_or_update_initial( if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.DnssecConfig: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,48 +88,43 @@ async def _create_or_update_initial( api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, if_none_match=if_none_match, api_version=api_version, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DnssecConfig", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnssecConfig", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } - @distributed_trace_async async def begin_create_or_update( self, @@ -149,14 +149,6 @@ async def begin_create_or_update( prevent updating existing DNSSEC configuration. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DnssecConfig or the result of cls(response) :rtype: @@ -185,12 +177,13 @@ 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("DnssecConfig", pipeline_response) + deserialized = self._deserialize("DnssecConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -200,22 +193,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DnssecConfig].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return AsyncLROPoller[_models.DnssecConfig]( + 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, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,29 +220,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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) @@ -259,12 +253,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -281,14 +275,6 @@ async def begin_delete( DNSSEC configuration. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -304,7 +290,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, zone_name=zone_name, if_match=if_match, @@ -314,11 +300,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -327,17 +314,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.DnssecConfig: @@ -348,12 +331,11 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnssecConfig or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,21 +351,19 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> ) cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -392,16 +372,12 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnssecConfig", pipeline_response) + deserialized = self._deserialize("DnssecConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return deserialized # type: ignore @distributed_trace def list_by_dns_zone( @@ -414,7 +390,6 @@ def list_by_dns_zone( :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnssecConfig or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] @@ -428,7 +403,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.DnssecConfigListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -439,17 +414,15 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -460,14 +433,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DnssecConfigListResult", pipeline_response) @@ -477,11 +449,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -492,7 +464,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py index 3809638cfe13..d2a269ec3b99 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._record_sets_operations import ( build_create_or_update_request, build_delete_request, @@ -39,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -98,7 +101,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -111,7 +113,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -131,7 +133,7 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -139,7 +141,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -152,7 +153,7 @@ async def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -170,21 +171,17 @@ async def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +206,7 @@ async def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -220,16 +217,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -238,16 +233,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -289,7 +280,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +292,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -324,7 +314,7 @@ async def create_or_update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -335,7 +325,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +337,7 @@ async def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -368,8 +357,8 @@ async def create_or_update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -377,15 +366,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +395,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -422,16 +407,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -440,21 +423,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, @@ -483,12 +458,11 @@ async def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,7 +478,7 @@ async def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -512,16 +486,14 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,11 +503,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -559,12 +527,11 @@ async def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,23 +547,21 @@ async def get( ) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -605,16 +570,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -643,7 +604,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] @@ -657,7 +617,7 @@ def list_by_type( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,7 +628,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -676,12 +636,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -692,14 +650,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -709,11 +666,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,10 +682,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -752,7 +705,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] @@ -766,7 +718,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -777,19 +729,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -800,14 +750,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -817,11 +766,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,10 +782,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -860,7 +805,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] @@ -874,7 +818,7 @@ def list_all_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -885,19 +829,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -908,14 +850,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -925,11 +866,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -940,7 +881,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py index ae6aceff46e4..b081a4f710ca 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._zones_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +100,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +110,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -121,7 +125,7 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -132,7 +136,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -143,7 +146,7 @@ async def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -156,8 +159,8 @@ async def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -165,15 +168,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,7 +197,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -208,16 +207,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,25 +223,17 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,29 +247,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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) @@ -288,12 +280,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -311,14 +303,6 @@ async def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -334,7 +318,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, zone_name=zone_name, if_match=if_match, @@ -344,11 +328,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -357,17 +342,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -378,12 +359,11 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,21 +379,19 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> ) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -422,16 +400,12 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload async def update( @@ -460,7 +434,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -471,7 +444,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -485,7 +458,7 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -493,7 +466,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -504,7 +476,7 @@ async def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -516,21 +488,17 @@ async def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,7 +523,7 @@ async def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -564,16 +532,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -582,16 +548,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -605,7 +567,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] @@ -619,7 +580,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,17 +591,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -651,14 +610,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -668,11 +626,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -684,10 +642,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -695,7 +649,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] @@ -709,7 +662,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,16 +673,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -740,14 +691,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -757,11 +707,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,5 +722,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py index 5de5b1a76084..87ea6110fa87 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py @@ -623,6 +623,9 @@ class RecordSet(_serialization.Model): # pylint: disable=too-many-instance-attr :ivar target_resource: A reference to an azure resource from where the dns resource value is taken. :vartype target_resource: ~azure.mgmt.dns.v2023_07_01_preview.models.SubResource + :ivar traffic_management_profile: A reference to an azure traffic manager profile resource from + where the dns resource value is taken. + :vartype traffic_management_profile: ~azure.mgmt.dns.v2023_07_01_preview.models.SubResource :ivar a_records: The list of A records in the record set. :vartype a_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.ARecord] :ivar aaaa_records: The list of AAAA records in the record set. @@ -669,6 +672,7 @@ class RecordSet(_serialization.Model): # pylint: disable=too-many-instance-attr "fqdn": {"key": "properties.fqdn", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "target_resource": {"key": "properties.targetResource", "type": "SubResource"}, + "traffic_management_profile": {"key": "properties.trafficManagementProfile", "type": "SubResource"}, "a_records": {"key": "properties.ARecords", "type": "[ARecord]"}, "aaaa_records": {"key": "properties.AAAARecords", "type": "[AaaaRecord]"}, "mx_records": {"key": "properties.MXRecords", "type": "[MxRecord]"}, @@ -691,6 +695,7 @@ def __init__( metadata: Optional[Dict[str, str]] = None, ttl: Optional[int] = None, target_resource: Optional["_models.SubResource"] = None, + traffic_management_profile: Optional["_models.SubResource"] = None, a_records: Optional[List["_models.ARecord"]] = None, aaaa_records: Optional[List["_models.AaaaRecord"]] = None, mx_records: Optional[List["_models.MxRecord"]] = None, @@ -716,6 +721,9 @@ def __init__( :keyword target_resource: A reference to an azure resource from where the dns resource value is taken. :paramtype target_resource: ~azure.mgmt.dns.v2023_07_01_preview.models.SubResource + :keyword traffic_management_profile: A reference to an azure traffic manager profile resource + from where the dns resource value is taken. + :paramtype traffic_management_profile: ~azure.mgmt.dns.v2023_07_01_preview.models.SubResource :keyword a_records: The list of A records in the record set. :paramtype a_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.ARecord] :keyword aaaa_records: The list of AAAA records in the record set. @@ -753,6 +761,7 @@ def __init__( self.fqdn = None self.provisioning_state = None self.target_resource = target_resource + self.traffic_management_profile = traffic_management_profile self.a_records = a_records self.aaaa_records = aaaa_records self.mx_records = mx_records @@ -823,7 +832,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -1195,7 +1204,7 @@ class Zone(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py index a39b65abfbea..5e7472c19d46 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ 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, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_get_by_target_resources_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +98,6 @@ def get_by_target_resources( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,16 +105,15 @@ def get_by_target_resources( @overload def get_by_target_resources( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: @@ -120,22 +121,19 @@ def get_by_target_resources( @distributed_trace def get_by_target_resources( - self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **kwargs: Any + self, parameters: Union[_models.DnsResourceReferenceRequest, IO[bytes]], **kwargs: Any ) -> _models.DnsResourceReferenceResult: """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. Is either a - DnsResourceReferenceRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + DnsResourceReferenceRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest or + IO[bytes] :return: DnsResourceReferenceResult or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,22 +158,20 @@ def get_by_target_resources( else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") - request = build_get_by_target_resources_request( + _request = build_get_by_target_resources_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.get_by_target_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,13 +180,9 @@ def get_by_target_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_target_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py index eab2f2498917..47f9033b8a82 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -15,13 +16,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +31,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +71,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +108,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,7 +141,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -169,7 +174,7 @@ def build_list_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,8 +212,8 @@ def _create_or_update_initial( if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.DnssecConfig: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -222,48 +227,43 @@ def _create_or_update_initial( api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, if_none_match=if_none_match, api_version=api_version, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DnssecConfig", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnssecConfig", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } - @distributed_trace def begin_create_or_update( self, @@ -288,14 +288,6 @@ def begin_create_or_update( prevent updating existing DNSSEC configuration. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DnssecConfig or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] @@ -323,12 +315,13 @@ 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("DnssecConfig", pipeline_response) + deserialized = self._deserialize("DnssecConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -338,22 +331,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DnssecConfig].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return LROPoller[_models.DnssecConfig]( + 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, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,29 +358,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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) @@ -397,12 +391,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -419,14 +413,6 @@ def begin_delete( DNSSEC configuration. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +428,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, zone_name=zone_name, if_match=if_match, @@ -452,11 +438,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -465,17 +452,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.DnssecConfig: @@ -486,12 +469,11 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnssecConfig or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,21 +489,19 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model ) cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -530,16 +510,12 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnssecConfig", pipeline_response) + deserialized = self._deserialize("DnssecConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" - } + return deserialized # type: ignore @distributed_trace def list_by_dns_zone( @@ -552,7 +528,6 @@ def list_by_dns_zone( :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnssecConfig or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] :raises ~azure.core.exceptions.HttpResponseError: @@ -565,7 +540,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.DnssecConfigListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,17 +551,15 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -597,14 +570,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DnssecConfigListResult", pipeline_response) @@ -614,11 +586,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -629,7 +601,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py index 940dd2095a34..0f31e1af61dc 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +124,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +174,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,7 +218,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -256,7 +259,7 @@ def build_list_by_type_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -299,7 +302,7 @@ def build_list_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -342,7 +345,7 @@ def build_list_all_by_dns_zone_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -412,7 +415,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +427,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -445,7 +447,7 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -453,7 +455,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -466,7 +467,7 @@ def update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.RecordSet: @@ -484,21 +485,17 @@ def update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. Is either a RecordSet type or a - IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,7 +520,7 @@ def update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -534,16 +531,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,16 +547,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -603,7 +594,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -616,7 +606,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -638,7 +628,7 @@ def create_or_update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -649,7 +639,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: @@ -662,7 +651,7 @@ def create_or_update( zone_name: str, relative_record_set_name: str, record_type: Union[str, _models.RecordType], - parameters: Union[_models.RecordSet, IO], + parameters: Union[_models.RecordSet, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -682,8 +671,8 @@ def create_or_update( "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a RecordSet - type or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet or IO[bytes] :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -691,15 +680,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -724,7 +709,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "RecordSet") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -736,16 +721,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -754,21 +737,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecordSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -797,12 +772,11 @@ def delete( # pylint: disable=inconsistent-return-statements record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -818,7 +792,7 @@ def delete( # pylint: disable=inconsistent-return-statements ) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, @@ -826,16 +800,14 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -845,11 +817,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -873,12 +841,11 @@ def get( :param record_type: The type of DNS record in this record set. Known values are: "A", "AAAA", "CAA", "CNAME", "MX", "NS", "PTR", "SOA", "SRV", "TXT", "TLSA", "DS", and "NAPTR". Required. :type record_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.RecordType - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -894,23 +861,21 @@ def get( ) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, relative_record_set_name=relative_record_set_name, record_type=record_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -919,16 +884,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecordSet", pipeline_response) + deserialized = self._deserialize("RecordSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_type( @@ -957,7 +918,6 @@ def list_by_type( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -970,7 +930,7 @@ def list_by_type( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -981,7 +941,7 @@ def list_by_type( def prepare_request(next_link=None): if not next_link: - request = build_list_by_type_request( + _request = build_list_by_type_request( resource_group_name=resource_group_name, zone_name=zone_name, record_type=record_type, @@ -989,12 +949,10 @@ def prepare_request(next_link=None): top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_type.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1005,14 +963,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1022,11 +979,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1038,10 +995,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_type.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}" - } - @distributed_trace def list_by_dns_zone( self, @@ -1065,7 +1018,6 @@ def list_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1078,7 +1030,7 @@ def list_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1089,19 +1041,17 @@ def list_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_by_dns_zone_request( + _request = build_list_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, recordsetnamesuffix=recordsetnamesuffix, api_version=api_version, - template_url=self.list_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1112,14 +1062,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1129,11 +1078,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1145,10 +1094,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets" - } - @distributed_trace def list_all_by_dns_zone( self, @@ -1172,7 +1117,6 @@ def list_all_by_dns_zone( filter the record set enumerations. If this parameter is specified, Enumeration will return only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -1185,7 +1129,7 @@ def list_all_by_dns_zone( ) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1196,19 +1140,17 @@ def list_all_by_dns_zone( def prepare_request(next_link=None): if not next_link: - request = build_list_all_by_dns_zone_request( + _request = build_list_all_by_dns_zone_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, top=top, record_set_name_suffix=record_set_name_suffix, api_version=api_version, - template_url=self.list_all_by_dns_zone.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1219,14 +1161,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecordSetListResult", pipeline_response) @@ -1236,11 +1177,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1251,7 +1192,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all_by_dns_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all" - } diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py index d3af1e1d3eb7..17e83ae3267b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +73,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +112,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +145,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,7 +179,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +215,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -236,7 +241,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -300,7 +305,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +315,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -326,7 +330,7 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -337,7 +341,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +351,7 @@ def create_or_update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.Zone, IO], + parameters: Union[_models.Zone, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -361,8 +364,8 @@ def create_or_update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a Zone type - or a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -370,15 +373,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +402,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "Zone") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -413,16 +412,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -431,25 +428,17 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Zone", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,29 +452,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2023-07-01-preview") ) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) 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) @@ -493,12 +485,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -516,14 +508,6 @@ def begin_delete( Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -539,7 +523,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, zone_name=zone_name, if_match=if_match, @@ -549,11 +533,12 @@ 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 if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -562,17 +547,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: @@ -583,12 +564,11 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model :type resource_group_name: str :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -604,21 +584,19 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model ) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -627,16 +605,12 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @overload def update( @@ -665,7 +639,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -676,7 +649,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -690,7 +663,7 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -698,7 +671,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: @@ -709,7 +681,7 @@ def update( self, resource_group_name: str, zone_name: str, - parameters: Union[_models.ZoneUpdate, IO], + parameters: Union[_models.ZoneUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Zone: @@ -721,21 +693,17 @@ def update( :param zone_name: The name of the DNS zone (without a terminating dot). Required. :type zone_name: str :param parameters: Parameters supplied to the Update operation. Is either a ZoneUpdate type or - a IO type. Required. - :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate or IO + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate or IO[bytes] :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone or the result of cls(response) :rtype: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -760,7 +728,7 @@ def update( else: _json = self._serialize.body(parameters, "ZoneUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, zone_name=zone_name, subscription_id=self._config.subscription_id, @@ -769,16 +737,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -787,16 +753,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Zone", pipeline_response) + deserialized = self._deserialize("Zone", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -810,7 +772,6 @@ def list_by_resource_group( :param top: The maximum number of record sets to return. If not specified, returns up to 100 record sets. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -823,7 +784,7 @@ def list_by_resource_group( ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -834,17 +795,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -855,14 +814,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -872,11 +830,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -888,10 +846,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zone"]: """Lists the DNS zones in all resource groups in a subscription. @@ -899,7 +853,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 zones. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Zone or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] :raises ~azure.core.exceptions.HttpResponseError: @@ -912,7 +865,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo ) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -923,16 +876,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -943,14 +894,13 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ZoneListResult", pipeline_response) @@ -960,11 +910,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -975,5 +925,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_aaaa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_aaaa_recordset.py index 00e8ef3648c3..02fc0284740e 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_aaaa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_aaaa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset.py index e7f7a7b974c9..709f9181b537 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset_alias.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset_alias.py index 9dfed155760e..c60545c65f34 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset_alias.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_arecordset_alias.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_caa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_caa_recordset.py index 2fca577af508..b17a3be834eb 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_caa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_caa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_cname_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_cname_recordset.py index f4a95dba4d5f..3640094a6e43 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_cname_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_cname_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_mx_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_mx_recordset.py index 34e619e7351a..a0632e6e5dc4 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_mx_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_mx_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ns_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ns_recordset.py index cc9e69a52e01..823ff79ba9c3 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ns_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ns_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ptr_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ptr_recordset.py index 46484ed40ae4..bd23440ab774 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ptr_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_ptr_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_soa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_soa_recordset.py index c068aa72e163..b351fd5c1296 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_soa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_soa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_srv_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_srv_recordset.py index 5b6ffbbff38e..dff301f8ee81 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_srv_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_srv_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_txt_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_txt_recordset.py index ea5ac613af01..1441860da87a 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_txt_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_txt_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_zone.py b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_zone.py index 88243d13fc40..5ca60f0f7a6f 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/create_or_update_zone.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_aaaa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_aaaa_recordset.py index 6bd27f988c9d..0a43a73a9c0b 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_aaaa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_aaaa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py index cfff26839fce..a4929fb595d1 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_caa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_caa_recordset.py index 10d27f10b046..a21a98d040ed 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_caa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_caa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_ptr_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_ptr_recordset.py index 25afc099cb78..d52e9fc05327 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_ptr_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_ptr_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_srv_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_srv_recordset.py index bba2191c1ac5..ea58aee18409 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_srv_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_srv_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_txt_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_txt_recordset.py index 4f64c1b1ee5b..556a2dce80b0 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_txt_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_txt_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py b/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py index c6415f59e60c..0b24ca99c9e6 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_aaaa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_aaaa_recordset.py index 8b90cf3adbdb..992eeaca9f8c 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_aaaa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_aaaa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_arecordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_arecordset.py index fa20c70e2c21..668bc53febb6 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_arecordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_caa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_caa_recordset.py index 7308650ec80d..01b060d9c4b8 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_caa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_caa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_cname_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_cname_recordset.py index bf447e8e82e6..553a45901a1c 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_cname_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_cname_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_dns_resource_reference.py b/sdk/network/azure-mgmt-dns/generated_samples/get_dns_resource_reference.py index 314e71d466aa..1e3287ebda1f 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_dns_resource_reference.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_dns_resource_reference.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_mx_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_mx_recordset.py index 9b8d01cbba91..bd570deda822 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_mx_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_mx_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_ns_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_ns_recordset.py index 5f515d03055f..c351bf95413c 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_ns_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_ns_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_ptr_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_ptr_recordset.py index dd159553280c..d61a64863b94 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_ptr_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_ptr_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_soa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_soa_recordset.py index 02c1b5682381..d05825b67e4d 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_soa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_soa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_srv_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_srv_recordset.py index 15e1987099c6..a24c2cbd6926 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_srv_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_srv_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_txt_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/get_txt_recordset.py index 405d76fedc4e..876b3122719e 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_txt_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_txt_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/get_zone.py b/sdk/network/azure-mgmt-dns/generated_samples/get_zone.py index 2fbba06f86c4..ac3aa991a01a 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/get_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/get_zone.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_aaaa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_aaaa_recordset.py index 86b19cecdf11..05b7c2c4ea65 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_aaaa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_aaaa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_arecordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_arecordset.py index 6c898c73b579..96411e7f4370 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_arecordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_caa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_caa_recordset.py index 38aa04edc2f0..952deaab0761 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_caa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_caa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_cname_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_cname_recordset.py index ea3c543c1f6b..61f213d7687a 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_cname_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_cname_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_mx_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_mx_recordset.py index 171622ab8204..3928e0271ce9 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_mx_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_mx_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_ns_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_ns_recordset.py index c4a412cf3d58..6cb75f2010db 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_ns_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_ns_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_ptr_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_ptr_recordset.py index 9dcf8c2507be..a7b340aa02a4 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_ptr_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_ptr_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_record_sets_by_zone.py b/sdk/network/azure-mgmt-dns/generated_samples/list_record_sets_by_zone.py index 5befbff6e0c6..a92b8b7552b8 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_record_sets_by_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_record_sets_by_zone.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="subid", ) - response = client.record_sets.list_by_dns_zone( + response = client.record_sets.list_all_by_dns_zone( resource_group_name="rg1", zone_name="zone1", ) diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_soa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_soa_recordset.py index 32d69bfddb6a..1be83cb21d37 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_soa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_soa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_srv_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_srv_recordset.py index 138f27f999ea..ab5d52ade6f1 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_srv_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_srv_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_txt_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/list_txt_recordset.py index 474fe9541e23..5c4ebddbae59 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_txt_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_txt_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_resource_group.py b/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_resource_group.py index 67af7bb5ec41..f354eb81df74 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_resource_group.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_subscription.py b/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_subscription.py index 65b6830939cf..2a9bf8b98935 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_subscription.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/list_zones_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_aaaa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_aaaa_recordset.py index ddf0f20b8c76..7fa443de3150 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_aaaa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_aaaa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_arecordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_arecordset.py index a53aea8ce03b..6dc0cbfe58ef 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_arecordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_caa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_caa_recordset.py index 9ef9e4b6fd80..dd1666c059c8 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_caa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_caa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_cname_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_cname_recordset.py index 92d2f95f10e3..769ebd53c9e1 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_cname_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_cname_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_mx_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_mx_recordset.py index 484461698e3f..6dcd8c73330b 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_mx_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_mx_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_ns_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_ns_recordset.py index 348d41d936db..285b9b0ef086 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_ns_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_ns_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_ptr_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_ptr_recordset.py index 805c17575e9c..60d1b86ea755 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_ptr_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_ptr_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_soa_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_soa_recordset.py index 61c97104473f..fe01c216609b 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_soa_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_soa_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_srv_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_srv_recordset.py index a7c39c5882dd..20e71b33d030 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_srv_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_srv_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_txt_recordset.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_txt_recordset.py index 4329574087fe..e8b06d2643cb 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_txt_recordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_txt_recordset.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_samples/patch_zone.py b/sdk/network/azure-mgmt-dns/generated_samples/patch_zone.py index 18522c3e8634..05a0bb4d512a 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/patch_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/patch_zone.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dns import DnsManagementClient """ diff --git a/sdk/network/azure-mgmt-dns/generated_tests/conftest.py b/sdk/network/azure-mgmt-dns/generated_tests/conftest.py new file mode 100644 index 000000000000..f0a4cf60779b --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + dnsmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_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-dns/generated_tests/test_dns_management_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_operations.py new file mode 100644 index 000000000000..a5ae2686f316 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_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.dns import DnsManagementClient + +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 TestDnsManagementDnsResourceReferenceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_target_resources(self, resource_group): + response = self.client.dns_resource_reference.get_by_target_resources( + parameters={"targetResources": [{"id": "str"}]}, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_operations_async.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_operations_async.py new file mode 100644 index 000000000000..c997cef4e57c --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_dns_resource_reference_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.dns.aio import DnsManagementClient + +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 TestDnsManagementDnsResourceReferenceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_target_resources(self, resource_group): + response = await self.client.dns_resource_reference.get_by_target_resources( + parameters={"targetResources": [{"id": "str"}]}, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations.py new file mode 100644 index 000000000000..e050ab0651ca --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations.py @@ -0,0 +1,170 @@ +# 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.dns import DnsManagementClient + +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 TestDnsManagementRecordSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.record_sets.update( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + parameters={ + "AAAARecords": [{"ipv6Address": "str"}], + "ARecords": [{"ipv4Address": "str"}], + "CNAMERecord": {"cname": "str"}, + "MXRecords": [{"exchange": "str", "preference": 0}], + "NSRecords": [{"nsdname": "str"}], + "PTRRecords": [{"ptrdname": "str"}], + "SOARecord": { + "email": "str", + "expireTime": 0, + "host": "str", + "minimumTTL": 0, + "refreshTime": 0, + "retryTime": 0, + "serialNumber": 0, + }, + "SRVRecords": [{"port": 0, "priority": 0, "target": "str", "weight": 0}], + "TTL": 0, + "TXTRecords": [{"value": ["str"]}], + "caaRecords": [{"flags": 0, "tag": "str", "value": "str"}], + "etag": "str", + "fqdn": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "targetResource": {"id": "str"}, + "type": "str", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.record_sets.create_or_update( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + parameters={ + "AAAARecords": [{"ipv6Address": "str"}], + "ARecords": [{"ipv4Address": "str"}], + "CNAMERecord": {"cname": "str"}, + "MXRecords": [{"exchange": "str", "preference": 0}], + "NSRecords": [{"nsdname": "str"}], + "PTRRecords": [{"ptrdname": "str"}], + "SOARecord": { + "email": "str", + "expireTime": 0, + "host": "str", + "minimumTTL": 0, + "refreshTime": 0, + "retryTime": 0, + "serialNumber": 0, + }, + "SRVRecords": [{"port": 0, "priority": 0, "target": "str", "weight": 0}], + "TTL": 0, + "TXTRecords": [{"value": ["str"]}], + "caaRecords": [{"flags": 0, "tag": "str", "value": "str"}], + "etag": "str", + "fqdn": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "targetResource": {"id": "str"}, + "type": "str", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.record_sets.delete( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.record_sets.get( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_type(self, resource_group): + response = self.client.record_sets.list_by_type( + resource_group_name=resource_group.name, + zone_name="str", + record_type="str", + api_version="2018-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_list_by_dns_zone(self, resource_group): + response = self.client.record_sets.list_by_dns_zone( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-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_list_all_by_dns_zone(self, resource_group): + response = self.client.record_sets.list_all_by_dns_zone( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations_async.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations_async.py new file mode 100644 index 000000000000..08df0a1ece9b --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_record_sets_operations_async.py @@ -0,0 +1,171 @@ +# 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.dns.aio import DnsManagementClient + +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 TestDnsManagementRecordSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.record_sets.update( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + parameters={ + "AAAARecords": [{"ipv6Address": "str"}], + "ARecords": [{"ipv4Address": "str"}], + "CNAMERecord": {"cname": "str"}, + "MXRecords": [{"exchange": "str", "preference": 0}], + "NSRecords": [{"nsdname": "str"}], + "PTRRecords": [{"ptrdname": "str"}], + "SOARecord": { + "email": "str", + "expireTime": 0, + "host": "str", + "minimumTTL": 0, + "refreshTime": 0, + "retryTime": 0, + "serialNumber": 0, + }, + "SRVRecords": [{"port": 0, "priority": 0, "target": "str", "weight": 0}], + "TTL": 0, + "TXTRecords": [{"value": ["str"]}], + "caaRecords": [{"flags": 0, "tag": "str", "value": "str"}], + "etag": "str", + "fqdn": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "targetResource": {"id": "str"}, + "type": "str", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.record_sets.create_or_update( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + parameters={ + "AAAARecords": [{"ipv6Address": "str"}], + "ARecords": [{"ipv4Address": "str"}], + "CNAMERecord": {"cname": "str"}, + "MXRecords": [{"exchange": "str", "preference": 0}], + "NSRecords": [{"nsdname": "str"}], + "PTRRecords": [{"ptrdname": "str"}], + "SOARecord": { + "email": "str", + "expireTime": 0, + "host": "str", + "minimumTTL": 0, + "refreshTime": 0, + "retryTime": 0, + "serialNumber": 0, + }, + "SRVRecords": [{"port": 0, "priority": 0, "target": "str", "weight": 0}], + "TTL": 0, + "TXTRecords": [{"value": ["str"]}], + "caaRecords": [{"flags": 0, "tag": "str", "value": "str"}], + "etag": "str", + "fqdn": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "targetResource": {"id": "str"}, + "type": "str", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.record_sets.delete( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.record_sets.get( + resource_group_name=resource_group.name, + zone_name="str", + relative_record_set_name="str", + record_type="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_type(self, resource_group): + response = self.client.record_sets.list_by_type( + resource_group_name=resource_group.name, + zone_name="str", + record_type="str", + api_version="2018-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_list_by_dns_zone(self, resource_group): + response = self.client.record_sets.list_by_dns_zone( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-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_list_all_by_dns_zone(self, resource_group): + response = self.client.record_sets.list_all_by_dns_zone( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations.py new file mode 100644 index 000000000000..869781058c57 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations.py @@ -0,0 +1,104 @@ +# 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.dns import DnsManagementClient + +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 TestDnsManagementZonesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.zones.create_or_update( + resource_group_name=resource_group.name, + zone_name="str", + parameters={ + "location": "str", + "etag": "str", + "id": "str", + "maxNumberOfRecordSets": 0, + "maxNumberOfRecordsPerRecordSet": 0, + "name": "str", + "nameServers": ["str"], + "numberOfRecordSets": 0, + "registrationVirtualNetworks": [{"id": "str"}], + "resolutionVirtualNetworks": [{"id": "str"}], + "tags": {"str": "str"}, + "type": "str", + "zoneType": "Public", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.zones.begin_delete( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-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_get(self, resource_group): + response = self.client.zones.get( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.zones.update( + resource_group_name=resource_group.name, + zone_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.zones.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-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_list(self, resource_group): + response = self.client.zones.list( + api_version="2018-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations_async.py b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_operations_async.py new file mode 100644 index 000000000000..8523aa51c0e2 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/generated_tests/test_dns_management_zones_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.dns.aio import DnsManagementClient + +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 TestDnsManagementZonesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.zones.create_or_update( + resource_group_name=resource_group.name, + zone_name="str", + parameters={ + "location": "str", + "etag": "str", + "id": "str", + "maxNumberOfRecordSets": 0, + "maxNumberOfRecordsPerRecordSet": 0, + "name": "str", + "nameServers": ["str"], + "numberOfRecordSets": 0, + "registrationVirtualNetworks": [{"id": "str"}], + "resolutionVirtualNetworks": [{"id": "str"}], + "tags": {"str": "str"}, + "type": "str", + "zoneType": "Public", + }, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.zones.begin_delete( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-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_get(self, resource_group): + response = await self.client.zones.get( + resource_group_name=resource_group.name, + zone_name="str", + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.zones.update( + resource_group_name=resource_group.name, + zone_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2018-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.zones.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-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_list(self, resource_group): + response = self.client.zones.list( + api_version="2018-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/network/azure-mgmt-dns/setup.py b/sdk/network/azure-mgmt-dns/setup.py index 2c8904584a19..248497242b18 100644 --- a/sdk/network/azure-mgmt-dns/setup.py +++ b/sdk/network/azure-mgmt-dns/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", ) From e5f9589ebd2bdddb59137d0c0856f44a37f85713 Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 Date: Wed, 25 Sep 2024 12:59:38 +0800 Subject: [PATCH 2/4] update-testcase --- sdk/network/azure-mgmt-dns/assets.json | 6 -- .../azure-mgmt-dns/dev_requirements.txt | 3 +- sdk/network/azure-mgmt-dns/tests/conftest.py | 66 ++++++------------- ..._management_zones_operations_async_test.py | 29 ++++++++ ...st_dns_management_zones_operations_test.py | 29 ++++++++ ...test_mgmt_dns.py => test_mgmt_dns_test.py} | 4 +- 6 files changed, 84 insertions(+), 53 deletions(-) delete mode 100644 sdk/network/azure-mgmt-dns/assets.json create mode 100644 sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_async_test.py create mode 100644 sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_test.py rename sdk/network/azure-mgmt-dns/tests/{test_mgmt_dns.py => test_mgmt_dns_test.py} (99%) diff --git a/sdk/network/azure-mgmt-dns/assets.json b/sdk/network/azure-mgmt-dns/assets.json deleted file mode 100644 index e6ccddd501dc..000000000000 --- a/sdk/network/azure-mgmt-dns/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "python", - "TagPrefix": "python/network/azure-mgmt-dns", - "Tag": "python/network/azure-mgmt-dns_85357eb011" -} diff --git a/sdk/network/azure-mgmt-dns/dev_requirements.txt b/sdk/network/azure-mgmt-dns/dev_requirements.txt index 3a799826b705..7ad65554270c 100644 --- a/sdk/network/azure-mgmt-dns/dev_requirements.txt +++ b/sdk/network/azure-mgmt-dns/dev_requirements.txt @@ -1,4 +1,5 @@ -e ../../../tools/azure-sdk-tools -e ../azure-mgmt-network ../../identity/azure-identity -azure-mgmt-resource<=21.1.0 \ No newline at end of file +azure-mgmt-resource<=21.1.0 +aiohttp \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/tests/conftest.py b/sdk/network/azure-mgmt-dns/tests/conftest.py index 6ab86de70dae..f0a4cf60779b 100644 --- a/sdk/network/azure-mgmt-dns/tests/conftest.py +++ b/sdk/network/azure-mgmt-dns/tests/conftest.py @@ -1,59 +1,35 @@ +# 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. # -------------------------------------------------------------------------- import os -import platform import pytest -import sys - from dotenv import load_dotenv - -from devtools_testutils import test_proxy, add_general_regex_sanitizer, remove_batch_sanitizers -from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer - -# Ignore async tests for Python < 3.5 -collect_ignore_glob = [] -if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy": - collect_ignore_glob.append("*_async.py") +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) load_dotenv() + +# aovid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") + dnsmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + dnsmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsmanagement_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") - - # Remove the following sanitizers since certain fields are needed in tests and are non-sensitive: - # - AZSDK3493: $..name - remove_batch_sanitizers(["AZSDK3493"]) diff --git a/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_async_test.py b/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_async_test.py new file mode 100644 index 000000000000..f4dbfe3ac965 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_async_test.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.dns.aio import DnsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsManagementZonesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.zones.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_test.py b/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_test.py new file mode 100644 index 000000000000..60490421054e --- /dev/null +++ b/sdk/network/azure-mgmt-dns/tests/test_dns_management_zones_operations_test.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.dns import DnsManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsManagementZonesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.zones.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py similarity index 99% rename from sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py rename to sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py index 74fee108a8ae..3d5d0188257b 100644 --- a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py +++ b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# coding: utf-8 #------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -13,7 +13,9 @@ AzureMgmtRecordedTestCase, ResourceGroupPreparer, recorded_by_proxy, AzureMgmtPreparer, FakeResource ) +import pytest +@pytest.mark.live_test_only class VirtualNetworkPreparer(AzureMgmtPreparer): def __init__(self, name_prefix='pvtzonevnet'): super(VirtualNetworkPreparer, self).__init__(name_prefix, 24) From 2f492e7a2b09cf313a451a392e3c036a03777091 Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:45:23 +0800 Subject: [PATCH 3/4] Update CHANGELOG.md --- sdk/network/azure-mgmt-dns/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/network/azure-mgmt-dns/CHANGELOG.md b/sdk/network/azure-mgmt-dns/CHANGELOG.md index 63f318e09b94..b8f29a8324cd 100644 --- a/sdk/network/azure-mgmt-dns/CHANGELOG.md +++ b/sdk/network/azure-mgmt-dns/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 8.2.0 (2024-10-21) +## 8.2.0 (2024-10-22) ### Features Added From ea3e278d775403bc7ccaf485dabf9a406d84f930 Mon Sep 17 00:00:00 2001 From: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:13:53 +0800 Subject: [PATCH 4/4] Update test_mgmt_dns_test.py --- sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py index 3d5d0188257b..ab80fd433ad7 100644 --- a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py +++ b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns_test.py @@ -70,7 +70,8 @@ def create_resource(self, name, **kwargs): 'registration_virtual_network': registration_network, 'resolution_virtual_network': resolution_network } - + +@pytest.mark.live_test_only class TestMgmtDns(AzureMgmtRecordedTestCase): def setup_method(self, method):