From 1511ac940f8898a0f5f9f6683ca09b9118e7dd31 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 17 May 2023 23:30:13 +0000 Subject: [PATCH] CodeGen from PR 24037 in Azure/azure-rest-api-specs Merge 499c8f6ad403d2d002625d113034203dca7da98d into 173bb3b6fd5b1809fdbf347f67fccfa0440ac126 --- sdk/network/azure-mgmt-dns/_meta.json | 6 +- .../azure/mgmt/dns/_dns_management_client.py | 27 + .../azure/mgmt/dns/_serialization.py | 6 +- .../azure-mgmt-dns/azure/mgmt/dns/_version.py | 7 +- .../mgmt/dns/aio/_dns_management_client.py | 27 + .../mgmt/dns/v2016_04_01/_configuration.py | 8 +- .../dns/v2016_04_01/_dns_management_client.py | 2 +- .../azure/mgmt/dns/v2016_04_01/_version.py | 2 +- .../dns/v2016_04_01/aio/_configuration.py | 8 +- .../v2016_04_01/aio/_dns_management_client.py | 2 +- .../aio/operations/_record_sets_operations.py | 40 +- .../aio/operations/_zones_operations.py | 35 +- .../models/_dns_management_client_enums.py | 1 + .../dns/v2016_04_01/models/_models_py3.py | 4 +- .../operations/_record_sets_operations.py | 52 +- .../operations/_zones_operations.py | 45 +- .../dns/v2018_03_01_preview/_configuration.py | 8 +- .../_dns_management_client.py | 2 +- .../mgmt/dns/v2018_03_01_preview/_version.py | 2 +- .../v2018_03_01_preview/aio/_configuration.py | 8 +- .../aio/_dns_management_client.py | 2 +- .../aio/operations/_record_sets_operations.py | 59 +- .../aio/operations/_zones_operations.py | 56 +- .../operations/_record_sets_operations.py | 87 +- .../operations/_zones_operations.py | 80 +- .../mgmt/dns/v2018_05_01/_configuration.py | 8 +- .../dns/v2018_05_01/_dns_management_client.py | 2 +- .../azure/mgmt/dns/v2018_05_01/_version.py | 2 +- .../dns/v2018_05_01/aio/_configuration.py | 8 +- .../v2018_05_01/aio/_dns_management_client.py | 2 +- .../_dns_resource_reference_operations.py | 13 +- .../aio/operations/_record_sets_operations.py | 45 +- .../aio/operations/_zones_operations.py | 42 +- .../_dns_resource_reference_operations.py | 15 +- .../operations/_record_sets_operations.py | 59 +- .../operations/_zones_operations.py | 54 +- .../mgmt/dns/v2023_07_01_preview/__init__.py | 26 + .../dns/v2023_07_01_preview/_configuration.py | 66 + .../_dns_management_client.py | 103 ++ .../dns/v2023_07_01_preview/_metadata.json | 113 ++ .../mgmt/dns/v2023_07_01_preview/_patch.py | 20 + .../mgmt/dns/v2023_07_01_preview/_vendor.py | 30 + .../mgmt/dns/v2023_07_01_preview/_version.py | 9 + .../dns/v2023_07_01_preview/aio/__init__.py | 23 + .../v2023_07_01_preview/aio/_configuration.py | 66 + .../aio/_dns_management_client.py | 104 ++ .../dns/v2023_07_01_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 25 + .../_dns_resource_reference_operations.py | 161 ++ .../operations/_dnssec_configs_operations.py | 485 ++++++ .../aio/operations/_patch.py | 20 + .../aio/operations/_record_sets_operations.py | 931 +++++++++++ .../aio/operations/_zones_operations.py | 761 +++++++++ .../v2023_07_01_preview/models/__init__.py | 85 + .../models/_dns_management_client_enums.py | 44 + .../v2023_07_01_preview/models/_models_py3.py | 1363 +++++++++++++++++ .../dns/v2023_07_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 25 + .../_dns_resource_reference_operations.py | 193 +++ .../operations/_dnssec_configs_operations.py | 622 ++++++++ .../v2023_07_01_preview/operations/_patch.py | 20 + .../operations/_record_sets_operations.py | 1242 +++++++++++++++ .../operations/_zones_operations.py | 964 ++++++++++++ .../mgmt/dns/v2023_07_01_preview/py.typed | 1 + .../delete_aaaa_recordset.py | 3 +- .../generated_samples/delete_arecordset.py | 3 +- .../generated_samples/delete_caa_recordset.py | 3 +- .../generated_samples/delete_ptr_recordset.py | 3 +- .../generated_samples/delete_srv_recordset.py | 3 +- .../generated_samples/delete_txt_recordset.py | 3 +- .../generated_samples/delete_zone.py | 3 +- 71 files changed, 7938 insertions(+), 451 deletions(-) create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/__init__.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_patch.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/__init__.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_patch.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/__init__.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_patch.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/__init__.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_dns_management_client_enums.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_patch.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/__init__.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_patch.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py create mode 100644 sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/py.typed diff --git a/sdk/network/azure-mgmt-dns/_meta.json b/sdk/network/azure-mgmt-dns/_meta.json index 540170db91e5..74b985675c8b 100644 --- a/sdk/network/azure-mgmt-dns/_meta.json +++ b/sdk/network/azure-mgmt-dns/_meta.json @@ -1,11 +1,11 @@ { - "commit": "c4eb7d4facbb9312f435df8c8ffe5061bfb02890", + "commit": "fba4c8f5cb6b307f10d6844655031ec2e4b705ed", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.4.0", + "@autorest/python@6.4.12", "@autorest/modelerfour@4.24.3" ], - "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.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/dns/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.12 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/dns/resource-manager/readme.md" } \ No newline at end of file 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 47bb0338ce0c..f9b38178feeb 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 @@ -89,6 +89,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2016-04-01: :mod:`v2016_04_01.models` * 2018-03-01-preview: :mod:`v2018_03_01_preview.models` * 2018-05-01: :mod:`v2018_05_01.models` + * 2023-07-01-preview: :mod:`v2023_07_01_preview.models` """ if api_version == '2016-04-01': from .v2016_04_01 import models @@ -99,6 +100,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2018-05-01': from .v2018_05_01 import models return models + elif api_version == '2023-07-01-preview': + from .v2023_07_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -106,15 +110,32 @@ def dns_resource_reference(self): """Instance depends on the API version: * 2018-05-01: :class:`DnsResourceReferenceOperations` + * 2023-07-01-preview: :class:`DnsResourceReferenceOperations` """ api_version = self._get_api_version('dns_resource_reference') if api_version == '2018-05-01': from .v2018_05_01.operations import DnsResourceReferenceOperations as OperationClass + elif api_version == '2023-07-01-preview': + from .v2023_07_01_preview.operations import DnsResourceReferenceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'dns_resource_reference'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def dnssec_configs(self): + """Instance depends on the API version: + + * 2023-07-01-preview: :class:`DnssecConfigsOperations` + """ + api_version = self._get_api_version('dnssec_configs') + if api_version == '2023-07-01-preview': + from .v2023_07_01_preview.operations import DnssecConfigsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dnssec_configs'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def record_sets(self): """Instance depends on the API version: @@ -122,6 +143,7 @@ def record_sets(self): * 2016-04-01: :class:`RecordSetsOperations` * 2018-03-01-preview: :class:`RecordSetsOperations` * 2018-05-01: :class:`RecordSetsOperations` + * 2023-07-01-preview: :class:`RecordSetsOperations` """ api_version = self._get_api_version('record_sets') if api_version == '2016-04-01': @@ -130,6 +152,8 @@ def record_sets(self): from .v2018_03_01_preview.operations import RecordSetsOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import RecordSetsOperations as OperationClass + elif api_version == '2023-07-01-preview': + from .v2023_07_01_preview.operations import RecordSetsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'record_sets'".format(api_version)) self._config.api_version = api_version @@ -142,6 +166,7 @@ def zones(self): * 2016-04-01: :class:`ZonesOperations` * 2018-03-01-preview: :class:`ZonesOperations` * 2018-05-01: :class:`ZonesOperations` + * 2023-07-01-preview: :class:`ZonesOperations` """ api_version = self._get_api_version('zones') if api_version == '2016-04-01': @@ -150,6 +175,8 @@ def zones(self): from .v2018_03_01_preview.operations import ZonesOperations as OperationClass elif api_version == '2018-05-01': from .v2018_05_01.operations import ZonesOperations as OperationClass + elif api_version == '2023-07-01-preview': + from .v2023_07_01_preview.operations import ZonesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'zones'".format(api_version)) self._config.api_version = api_version 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 25467dfc00bb..e3cc6ce6ed6f 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_serialization.py @@ -631,7 +631,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -1273,7 +1273,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1297,7 +1297,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): 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 7ecb4edacbc7..a30a458f8b5b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py @@ -3,11 +3,6 @@ # 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. # -------------------------------------------------------------------------- -VERSION = "8.1.0b1" - +VERSION = "0.1.0" \ No newline at end of file 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 0d6e1fb9f864..460b95b2372d 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 @@ -89,6 +89,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2016-04-01: :mod:`v2016_04_01.models` * 2018-03-01-preview: :mod:`v2018_03_01_preview.models` * 2018-05-01: :mod:`v2018_05_01.models` + * 2023-07-01-preview: :mod:`v2023_07_01_preview.models` """ if api_version == '2016-04-01': from ..v2016_04_01 import models @@ -99,6 +100,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2018-05-01': from ..v2018_05_01 import models return models + elif api_version == '2023-07-01-preview': + from ..v2023_07_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -106,15 +110,32 @@ def dns_resource_reference(self): """Instance depends on the API version: * 2018-05-01: :class:`DnsResourceReferenceOperations` + * 2023-07-01-preview: :class:`DnsResourceReferenceOperations` """ api_version = self._get_api_version('dns_resource_reference') if api_version == '2018-05-01': from ..v2018_05_01.aio.operations import DnsResourceReferenceOperations as OperationClass + elif api_version == '2023-07-01-preview': + from ..v2023_07_01_preview.aio.operations import DnsResourceReferenceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'dns_resource_reference'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def dnssec_configs(self): + """Instance depends on the API version: + + * 2023-07-01-preview: :class:`DnssecConfigsOperations` + """ + api_version = self._get_api_version('dnssec_configs') + if api_version == '2023-07-01-preview': + from ..v2023_07_01_preview.aio.operations import DnssecConfigsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dnssec_configs'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def record_sets(self): """Instance depends on the API version: @@ -122,6 +143,7 @@ def record_sets(self): * 2016-04-01: :class:`RecordSetsOperations` * 2018-03-01-preview: :class:`RecordSetsOperations` * 2018-05-01: :class:`RecordSetsOperations` + * 2023-07-01-preview: :class:`RecordSetsOperations` """ api_version = self._get_api_version('record_sets') if api_version == '2016-04-01': @@ -130,6 +152,8 @@ def record_sets(self): from ..v2018_03_01_preview.aio.operations import RecordSetsOperations as OperationClass elif api_version == '2018-05-01': from ..v2018_05_01.aio.operations import RecordSetsOperations as OperationClass + elif api_version == '2023-07-01-preview': + from ..v2023_07_01_preview.aio.operations import RecordSetsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'record_sets'".format(api_version)) self._config.api_version = api_version @@ -142,6 +166,7 @@ def zones(self): * 2016-04-01: :class:`ZonesOperations` * 2018-03-01-preview: :class:`ZonesOperations` * 2018-05-01: :class:`ZonesOperations` + * 2023-07-01-preview: :class:`ZonesOperations` """ api_version = self._get_api_version('zones') if api_version == '2016-04-01': @@ -150,6 +175,8 @@ def zones(self): from ..v2018_03_01_preview.aio.operations import ZonesOperations as OperationClass elif api_version == '2018-05-01': from ..v2018_05_01.aio.operations import ZonesOperations as OperationClass + elif api_version == '2023-07-01-preview': + from ..v2023_07_01_preview.aio.operations import ZonesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'zones'".format(api_version)) self._config.api_version = api_version 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 c9e90d5fe9e0..4e75d86272e2 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ 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: Literal["2016-04-01"] = kwargs.pop("api_version", "2016-04-01") + api_version: str = kwargs.pop("api_version", "2016-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 d098dc9e7154..467a18be39d7 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 @@ -52,7 +52,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 aa6530bfe9d9..e5754a47ce68 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.0b1" +VERSION = "1.0.0b1" 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 dc869414a604..c8dab4003166 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ 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: Literal["2016-04-01"] = kwargs.pop("api_version", "2016-04-01") + api_version: str = kwargs.pop("api_version", "2016-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 2d5bf393265c..9f56d49846e6 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 @@ -52,7 +52,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 ae612448b878..ef126ea4304a 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -38,10 +38,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -197,14 +193,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -227,8 +223,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,14 +392,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -426,8 +423,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,7 +493,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -513,8 +511,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,7 +567,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -585,8 +584,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -641,7 +641,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -698,8 +698,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -746,7 +747,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -802,8 +803,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 203617ac2166..f337d4fb30b7 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -39,10 +39,6 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -186,14 +182,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -215,8 +211,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,7 +251,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[Optional[_models.ZoneDeleteResult]] = kwargs.pop("cls", None) request = build_delete_request( @@ -270,8 +267,9 @@ async def _delete_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,7 +323,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneDeleteResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -393,7 +391,7 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -408,8 +406,9 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -449,7 +448,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -503,8 +502,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,7 +535,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -588,8 +588,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py index 28d380236533..55e4f7f4d557 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py @@ -60,6 +60,7 @@ class HttpStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE_UNAVAILABLE = "ServiceUnavailable" GATEWAY_TIMEOUT = "GatewayTimeout" HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" + CONTINUE_ENUM = "Continue" class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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 093b5616e4ca..c77a75b42bc6 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 @@ -730,7 +730,7 @@ class ZoneDeleteResult(_serialization.Model): "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - and "HttpVersionNotSupported". + "HttpVersionNotSupported", and "Continue". :vartype status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode :ivar request_id: :vartype request_id: str @@ -767,7 +767,7 @@ def __init__( "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - and "HttpVersionNotSupported". + "HttpVersionNotSupported", and "Continue". :paramtype status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode :keyword request_id: :paramtype request_id: 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 a7d7cf763ed9..b35bc1fd4e33 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -30,10 +30,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +50,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,7 +100,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -155,7 +151,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -199,7 +195,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,7 +239,7 @@ def build_list_by_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -287,7 +283,7 @@ def build_list_by_dns_zone_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -469,14 +465,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -499,8 +495,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -667,14 +664,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -698,8 +695,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -767,7 +765,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -785,8 +783,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -840,7 +839,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -857,8 +856,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -913,7 +913,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -970,8 +970,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1018,7 +1019,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1074,8 +1075,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 52583b5d412a..d6b548738321 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -32,10 +32,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +51,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -95,7 +91,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +124,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +157,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +189,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -354,14 +350,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -383,8 +379,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -422,7 +419,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[Optional[_models.ZoneDeleteResult]] = kwargs.pop("cls", None) request = build_delete_request( @@ -438,8 +435,9 @@ def _delete_initial( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -493,7 +491,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneDeleteResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -561,7 +559,7 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -576,8 +574,9 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -617,7 +616,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -671,8 +670,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -703,7 +703,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-04-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -756,8 +756,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 5766bb8f5eff..53a75711927c 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ 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: Literal["2018-03-01-preview"] = kwargs.pop("api_version", "2018-03-01-preview") + api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 423b91643e60..e5d9ecba918f 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 @@ -52,7 +52,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 aa6530bfe9d9..e5754a47ce68 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.0b1" +VERSION = "1.0.0b1" 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 2f4da1e043d0..178fce2cf59c 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ 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: Literal["2018-03-01-preview"] = kwargs.pop("api_version", "2018-03-01-preview") + api_version: str = kwargs.pop("api_version", "2018-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 9108f843bbe9..74eb61dc6ef0 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 @@ -52,7 +52,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 ef1cf62c87ef..10e594f7e610 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -39,10 +39,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -198,16 +194,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -230,8 +224,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -398,16 +393,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -431,8 +424,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -500,9 +494,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -520,8 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -575,9 +568,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -594,8 +585,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -651,9 +643,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -710,8 +700,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -759,9 +750,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -817,8 +806,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -866,9 +856,7 @@ def list_all_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -924,8 +912,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 226e58f647ff..e0a405968cfe 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -40,10 +40,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -187,16 +183,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -218,8 +212,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,9 +252,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -275,8 +268,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -323,9 +317,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -391,9 +383,7 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -408,8 +398,9 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -537,16 +528,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ZoneUpdate") @@ -567,8 +556,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -609,9 +599,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -665,8 +653,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -698,9 +687,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -753,8 +740,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 4dc617cae04f..92b614acb676 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -30,10 +30,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,9 +50,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -106,9 +100,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,9 +151,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -205,9 +195,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,9 +239,7 @@ def build_list_by_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -297,9 +283,7 @@ def build_list_by_dns_zone_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -342,9 +326,7 @@ def build_list_all_by_dns_zone_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -526,16 +508,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -558,8 +538,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -726,16 +707,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -759,8 +738,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -828,9 +808,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -848,8 +826,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -903,9 +882,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -922,8 +899,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -978,9 +956,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1037,8 +1013,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1085,9 +1062,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1143,8 +1118,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1191,9 +1167,7 @@ def list_all_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1249,8 +1223,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 7faf06a9991d..4fa1a3f98b3f 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -32,10 +32,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,9 +51,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,9 +91,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,9 +124,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,9 +157,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -207,9 +195,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -241,9 +227,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -404,16 +388,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -435,8 +417,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -474,9 +457,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -492,8 +473,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -540,9 +522,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -608,9 +588,7 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -625,8 +603,9 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -754,16 +733,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ZoneUpdate") @@ -784,8 +761,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -825,9 +803,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -881,8 +857,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -913,9 +890,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-03-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01-preview")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -968,8 +943,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 ccd82e5d7606..3ff9c5f8aaba 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -43,7 +37,7 @@ 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: Literal["2018-05-01"] = kwargs.pop("api_version", "2018-05-01") + api_version: str = kwargs.pop("api_version", "2018-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 4cf3a3dbc29d..196ae1838efd 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 @@ -56,7 +56,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 aa6530bfe9d9..e5754a47ce68 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.0b1" +VERSION = "1.0.0b1" 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 8a664a66ae68..f810803dcb0f 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 @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -43,7 +37,7 @@ 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: Literal["2018-05-01"] = kwargs.pop("api_version", "2018-05-01") + api_version: str = kwargs.pop("api_version", "2018-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 ce8a3c8a4f87..286721dbc3e2 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 @@ -56,7 +56,7 @@ def __init__( self._config = DnsManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) 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 049142466fd0..84435612f811 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._dns_resource_reference_operations import build_get_by_target_resources_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -117,14 +113,14 @@ async def get_by_target_resources( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResourceReferenceResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") @@ -142,8 +138,9 @@ async def get_by_target_resources( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 1ee6ed50a5d4..03334f7630b6 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -39,10 +39,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -195,14 +191,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -225,8 +221,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,14 +387,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -421,8 +418,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -489,7 +487,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -507,8 +505,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -561,7 +560,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -578,8 +577,9 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,7 +633,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -690,8 +690,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -737,7 +738,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -793,8 +794,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -840,7 +842,7 @@ def list_all_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -896,8 +898,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 3f96b9d1390d..90281e31c22d 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -40,10 +40,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -184,14 +180,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -213,8 +209,9 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,7 +249,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -268,8 +265,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -315,7 +313,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -380,7 +378,7 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -395,8 +393,9 @@ async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,14 +520,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ZoneUpdate") @@ -549,8 +548,9 @@ async def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -589,7 +589,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -643,8 +643,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -675,7 +676,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -728,8 +729,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 8655d20299b6..91735ebd7047 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +39,7 @@ def build_get_by_target_resources_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,14 +145,14 @@ def get_by_target_resources( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResourceReferenceResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") @@ -174,8 +170,9 @@ def get_by_target_resources( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 b0bab7d25e27..3785e2c9ea57 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -30,10 +30,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +50,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -102,7 +98,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +147,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +189,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +231,7 @@ def build_list_by_type_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -277,7 +273,7 @@ def build_list_by_dns_zone_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +314,7 @@ def build_list_all_by_dns_zone_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -495,14 +491,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -525,8 +521,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -690,14 +687,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecordSet") @@ -721,8 +718,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -789,7 +787,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -807,8 +805,9 @@ def delete( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -861,7 +860,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) request = build_get_request( @@ -878,8 +877,9 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -933,7 +933,7 @@ def list_by_type( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -990,8 +990,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1037,7 +1038,7 @@ def list_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1093,8 +1094,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1140,7 +1142,7 @@ def list_all_by_dns_zone( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) error_map = { @@ -1196,8 +1198,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response 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 b1da4ef54ec0..0947c7aa60d0 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -32,10 +32,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +51,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +120,7 @@ def build_get_request(resource_group_name: str, zone_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +151,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +187,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -221,7 +217,7 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -379,14 +375,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Zone") @@ -408,8 +404,9 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -447,7 +444,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -463,8 +460,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -510,7 +508,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -575,7 +573,7 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) request = build_get_request( @@ -590,8 +588,9 @@ def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _model request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -716,14 +715,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Zone] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ZoneUpdate") @@ -744,8 +743,9 @@ def update( request = _convert_request(request) request.url = self._client.format_url(request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -784,7 +784,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -838,8 +838,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -870,7 +871,7 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Zo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-05-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01")) cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -923,8 +924,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/__init__.py new file mode 100644 index 000000000000..23ee0cabde53 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_management_client import DnsManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DnsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() 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 new file mode 100644 index 000000000000..319d99ef1d1f --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + 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._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) 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 new file mode 100644 index 000000000000..0c5db9d40f93 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_dns_management_client.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DnsManagementClientConfiguration +from .operations import DnsResourceReferenceOperations, DnssecConfigsOperations, RecordSetsOperations, ZonesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DnsManagementClient: # pylint: disable=client-accepts-api-version-keyword + """The DNS Management Client. + + :ivar dnssec_configs: DnssecConfigsOperations operations + :vartype dnssec_configs: azure.mgmt.dns.v2023_07_01_preview.operations.DnssecConfigsOperations + :ivar record_sets: RecordSetsOperations operations + :vartype record_sets: azure.mgmt.dns.v2023_07_01_preview.operations.RecordSetsOperations + :ivar zones: ZonesOperations operations + :vartype zones: azure.mgmt.dns.v2023_07_01_preview.operations.ZonesOperations + :ivar dns_resource_reference: DnsResourceReferenceOperations operations + :vartype dns_resource_reference: + azure.mgmt.dns.v2023_07_01_preview.operations.DnsResourceReferenceOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.dnssec_configs = DnssecConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resource_reference = DnsResourceReferenceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "DnsManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..4448f4ce9b45 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_metadata.json @@ -0,0 +1,113 @@ +{ + "chosen_version": "2023-07-01-preview", + "total_api_version_list": ["2023-07-01-preview"], + "client": { + "name": "DnsManagementClient", + "filename": "_dns_management_client", + "description": "The DNS Management Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "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\"]}}}" + }, + "operation_groups": { + "dnssec_configs": "DnssecConfigsOperations", + "record_sets": "RecordSetsOperations", + "zones": "ZonesOperations", + "dns_resource_reference": "DnsResourceReferenceOperations" + } +} diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/__init__.py new file mode 100644 index 000000000000..e94042023e78 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_management_client import DnsManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DnsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() 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 new file mode 100644 index 000000000000..b7221faaef58 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + 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._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) 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 new file mode 100644 index 000000000000..1edc7489d9f0 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_dns_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DnsManagementClientConfiguration +from .operations import DnsResourceReferenceOperations, DnssecConfigsOperations, RecordSetsOperations, ZonesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DnsManagementClient: # pylint: disable=client-accepts-api-version-keyword + """The DNS Management Client. + + :ivar dnssec_configs: DnssecConfigsOperations operations + :vartype dnssec_configs: + azure.mgmt.dns.v2023_07_01_preview.aio.operations.DnssecConfigsOperations + :ivar record_sets: RecordSetsOperations operations + :vartype record_sets: azure.mgmt.dns.v2023_07_01_preview.aio.operations.RecordSetsOperations + :ivar zones: ZonesOperations operations + :vartype zones: azure.mgmt.dns.v2023_07_01_preview.aio.operations.ZonesOperations + :ivar dns_resource_reference: DnsResourceReferenceOperations operations + :vartype dns_resource_reference: + azure.mgmt.dns.v2023_07_01_preview.aio.operations.DnsResourceReferenceOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.dnssec_configs = DnssecConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resource_reference = DnsResourceReferenceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DnsManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..62aaadd3c149 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dnssec_configs_operations import DnssecConfigsOperations +from ._record_sets_operations import RecordSetsOperations +from ._zones_operations import ZonesOperations +from ._dns_resource_reference_operations import DnsResourceReferenceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DnssecConfigsOperations", + "RecordSetsOperations", + "ZonesOperations", + "DnsResourceReferenceOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() 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 new file mode 100644 index 000000000000..ce5d9bd4b811 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dns_resource_reference_operations.py @@ -0,0 +1,161 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnsResourceReferenceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.aio.DnsManagementClient`'s + :attr:`dns_resource_reference` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def get_by_target_resources( + self, parameters: _models.DnsResourceReferenceRequest, *, 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: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest + :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: + """ + + @overload + async def get_by_target_resources( + self, parameters: IO, *, 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 + :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: + """ + + @distributed_trace_async + async def get_by_target_resources( + self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResourceReferenceResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_target_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" + } 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 new file mode 100644 index 000000000000..86227323d2c2 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_dnssec_configs_operations.py @@ -0,0 +1,485 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dnssec_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_dns_zone_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnssecConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.aio.DnsManagementClient`'s + :attr:`dnssec_configs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DnssecConfig: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnssecConfig]: + """Creates or updates the DNSSEC configuration on a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of the DNSSEC configuration. Omit this value to always overwrite the + DNSSEC configuration. Specify the last-seen etag value to prevent accidentally overwriting any + concurrent changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow this DNSSEC configuration to be created, but to + 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnssecConfig", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the DNSSEC configuration on a DNS zone. This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of this DNSSEC configuration. Omit this value to always delete the + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.DnssecConfig: + """Gets the DNSSEC configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnssecConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" + } + + @distributed_trace + def list_by_dns_zone( + self, resource_group_name: str, zone_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DnssecConfig"]: + """Lists the DNSSEC configurations in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfigListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnssecConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 new file mode 100644 index 000000000000..81082e4c0205 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_record_sets_operations.py @@ -0,0 +1,931 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._record_sets_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_all_by_dns_zone_request, + build_list_by_dns_zone_request, + build_list_by_type_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RecordSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.aio.DnsManagementClient`'s + :attr:`record_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: _models.RecordSet, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + :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. 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: + """ + + @overload + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO + :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. 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: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: Union[_models.RecordSet, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecordSet") + + request = build_update_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, + if_match=if_match, + api_version=api_version, + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecordSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: _models.RecordSet, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + :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. + :type if_match: str + :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. 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :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. + :type if_match: str + :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. 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: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: Union[_models.RecordSet, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :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 + :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. + :type if_match: str + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecordSet") + + request = build_create_or_update_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, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a record set from a DNS zone. This operation cannot be undone. Record sets of type SOA + cannot be deleted (they are deleted when the DNS zone is deleted). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param if_match: The etag of the record set. Omit this value to always delete the current + 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_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, + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + **kwargs: Any + ) -> _models.RecordSet: + """Gets a record set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecordSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + } + + @distributed_trace + def list_by_type( + self, + resource_group_name: str, + zone_name: str, + record_type: Union[str, _models.RecordType], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RecordSet"]: + """Lists the record sets of a specified type in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :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 + :param recordsetnamesuffix: The suffix label of the record set name that has to be used to + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RecordSet"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :param recordsetnamesuffix: The suffix label of the record set name that has to be used to + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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" + } + + @distributed_trace + def list_all_by_dns_zone( + self, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RecordSet"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :param record_set_name_suffix: The suffix label of the record set name that has to be used to + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 new file mode 100644 index 000000000000..b551712a6255 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/aio/operations/_zones_operations.py @@ -0,0 +1,761 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._zones_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ZonesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.aio.DnsManagementClient`'s + :attr:`zones` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: _models.Zone, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone + :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 + :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. 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :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. 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: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: Union[_models.Zone, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Zone") + + 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, + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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 + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.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}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: + """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Zone", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @overload + async def update( + self, + resource_group_name: str, + zone_name: str, + parameters: _models.ZoneUpdate, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate + :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. 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: + """ + + @overload + async def update( + self, + resource_group_name: str, + zone_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. 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: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + zone_name: str, + parameters: Union[_models.ZoneUpdate, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ZoneUpdate") + + request = build_update_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, + 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) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Zone", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.Zone"]: + """Lists the DNS zones within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ZoneListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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. + + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ZoneListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/__init__.py new file mode 100644 index 000000000000..10608c93c697 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/__init__.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ARecord +from ._models_py3 import AaaaRecord +from ._models_py3 import CaaRecord +from ._models_py3 import CloudErrorBody +from ._models_py3 import CnameRecord +from ._models_py3 import DelegationSignerInfo +from ._models_py3 import Digest +from ._models_py3 import DnsResourceReference +from ._models_py3 import DnsResourceReferenceRequest +from ._models_py3 import DnsResourceReferenceResult +from ._models_py3 import DnssecConfig +from ._models_py3 import DnssecConfigListResult +from ._models_py3 import DsRecord +from ._models_py3 import MxRecord +from ._models_py3 import NaptrRecord +from ._models_py3 import NsRecord +from ._models_py3 import PtrRecord +from ._models_py3 import RecordSet +from ._models_py3 import RecordSetListResult +from ._models_py3 import RecordSetUpdateParameters +from ._models_py3 import Resource +from ._models_py3 import SigningKey +from ._models_py3 import SoaRecord +from ._models_py3 import SrvRecord +from ._models_py3 import SubResource +from ._models_py3 import SystemData +from ._models_py3 import TlsaRecord +from ._models_py3 import TxtRecord +from ._models_py3 import Zone +from ._models_py3 import ZoneListResult +from ._models_py3 import ZoneUpdate + +from ._dns_management_client_enums import CreatedByType +from ._dns_management_client_enums import RecordType +from ._dns_management_client_enums import ZoneType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ARecord", + "AaaaRecord", + "CaaRecord", + "CloudErrorBody", + "CnameRecord", + "DelegationSignerInfo", + "Digest", + "DnsResourceReference", + "DnsResourceReferenceRequest", + "DnsResourceReferenceResult", + "DnssecConfig", + "DnssecConfigListResult", + "DsRecord", + "MxRecord", + "NaptrRecord", + "NsRecord", + "PtrRecord", + "RecordSet", + "RecordSetListResult", + "RecordSetUpdateParameters", + "Resource", + "SigningKey", + "SoaRecord", + "SrvRecord", + "SubResource", + "SystemData", + "TlsaRecord", + "TxtRecord", + "Zone", + "ZoneListResult", + "ZoneUpdate", + "CreatedByType", + "RecordType", + "ZoneType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_dns_management_client_enums.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_dns_management_client_enums.py new file mode 100644 index 000000000000..5d083e0c6557 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_dns_management_client_enums.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class RecordType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RecordType.""" + + A = "A" + AAAA = "AAAA" + CAA = "CAA" + CNAME = "CNAME" + MX = "MX" + NS = "NS" + PTR = "PTR" + SOA = "SOA" + SRV = "SRV" + TXT = "TXT" + TLSA = "TLSA" + DS = "DS" + NAPTR = "NAPTR" + + +class ZoneType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of this DNS zone (Public or Private).""" + + PUBLIC = "Public" + PRIVATE = "Private" 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 new file mode 100644 index 000000000000..5de5b1a76084 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_models_py3.py @@ -0,0 +1,1363 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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 datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class AaaaRecord(_serialization.Model): + """An AAAA record. + + :ivar ipv6_address: The IPv6 address of this AAAA record. + :vartype ipv6_address: str + """ + + _attribute_map = { + "ipv6_address": {"key": "ipv6Address", "type": "str"}, + } + + def __init__(self, *, ipv6_address: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ipv6_address: The IPv6 address of this AAAA record. + :paramtype ipv6_address: str + """ + super().__init__(**kwargs) + self.ipv6_address = ipv6_address + + +class ARecord(_serialization.Model): + """An A record. + + :ivar ipv4_address: The IPv4 address of this A record. + :vartype ipv4_address: str + """ + + _attribute_map = { + "ipv4_address": {"key": "ipv4Address", "type": "str"}, + } + + def __init__(self, *, ipv4_address: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ipv4_address: The IPv4 address of this A record. + :paramtype ipv4_address: str + """ + super().__init__(**kwargs) + self.ipv4_address = ipv4_address + + +class CaaRecord(_serialization.Model): + """A CAA record. + + :ivar flags: The flags for this CAA record as an integer between 0 and 255. + :vartype flags: int + :ivar tag: The tag for this CAA record. + :vartype tag: str + :ivar value: The value for this CAA record. + :vartype value: str + """ + + _attribute_map = { + "flags": {"key": "flags", "type": "int"}, + "tag": {"key": "tag", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, *, flags: Optional[int] = None, tag: Optional[str] = None, value: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword flags: The flags for this CAA record as an integer between 0 and 255. + :paramtype flags: int + :keyword tag: The tag for this CAA record. + :paramtype tag: str + :keyword value: The value for this CAA record. + :paramtype value: str + """ + super().__init__(**kwargs) + self.flags = flags + self.tag = tag + self.value = value + + +class CloudErrorBody(_serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.dns.v2023_07_01_preview.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.dns.v2023_07_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class CnameRecord(_serialization.Model): + """A CNAME record. + + :ivar cname: The canonical name for this CNAME record. + :vartype cname: str + """ + + _attribute_map = { + "cname": {"key": "cname", "type": "str"}, + } + + def __init__(self, *, cname: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cname: The canonical name for this CNAME record. + :paramtype cname: str + """ + super().__init__(**kwargs) + self.cname = cname + + +class DelegationSignerInfo(_serialization.Model): + """The delegation signer information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar digest_algorithm_type: The digest algorithm type represents the standard digest algorithm + number used to construct the digest. See: + https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml. + :vartype digest_algorithm_type: int + :ivar digest_value: The digest value is a cryptographic hash value of the referenced DNSKEY + Resource Record. + :vartype digest_value: str + :ivar record: The record represents a delegation signer (DS) record. + :vartype record: str + """ + + _validation = { + "digest_algorithm_type": {"readonly": True}, + "digest_value": {"readonly": True}, + "record": {"readonly": True}, + } + + _attribute_map = { + "digest_algorithm_type": {"key": "digestAlgorithmType", "type": "int"}, + "digest_value": {"key": "digestValue", "type": "str"}, + "record": {"key": "record", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.digest_algorithm_type = None + self.digest_value = None + self.record = None + + +class Digest(_serialization.Model): + """A digest. + + :ivar algorithm_type: The digest algorithm type represents the standard digest algorithm number + used to construct the digest. See: + https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml. + :vartype algorithm_type: int + :ivar value: The digest value is a cryptographic hash value of the referenced DNSKEY Resource + Record. + :vartype value: str + """ + + _attribute_map = { + "algorithm_type": {"key": "algorithmType", "type": "int"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, algorithm_type: Optional[int] = None, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword algorithm_type: The digest algorithm type represents the standard digest algorithm + number used to construct the digest. See: + https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml. + :paramtype algorithm_type: int + :keyword value: The digest value is a cryptographic hash value of the referenced DNSKEY + Resource Record. + :paramtype value: str + """ + super().__init__(**kwargs) + self.algorithm_type = algorithm_type + self.value = value + + +class DnsResourceReference(_serialization.Model): + """Represents a single Azure resource and its referencing DNS records. + + :ivar dns_resources: A list of dns Records. + :vartype dns_resources: list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + :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 + """ + + _attribute_map = { + "dns_resources": {"key": "dnsResources", "type": "[SubResource]"}, + "target_resource": {"key": "targetResource", "type": "SubResource"}, + } + + def __init__( + self, + *, + dns_resources: Optional[List["_models.SubResource"]] = None, + target_resource: Optional["_models.SubResource"] = None, + **kwargs: Any + ) -> None: + """ + :keyword dns_resources: A list of dns Records. + :paramtype dns_resources: list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + :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 + """ + super().__init__(**kwargs) + self.dns_resources = dns_resources + self.target_resource = target_resource + + +class DnsResourceReferenceRequest(_serialization.Model): + """Represents the properties of the Dns Resource Reference Request. + + :ivar target_resources: A list of references to azure resources for which referencing dns + records need to be queried. + :vartype target_resources: list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + """ + + _attribute_map = { + "target_resources": {"key": "properties.targetResources", "type": "[SubResource]"}, + } + + def __init__(self, *, target_resources: Optional[List["_models.SubResource"]] = None, **kwargs: Any) -> None: + """ + :keyword target_resources: A list of references to azure resources for which referencing dns + records need to be queried. + :paramtype target_resources: list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + """ + super().__init__(**kwargs) + self.target_resources = target_resources + + +class DnsResourceReferenceResult(_serialization.Model): + """Represents the properties of the Dns Resource Reference Result. + + :ivar dns_resource_references: The result of dns resource reference request. A list of dns + resource references for each of the azure resource in the request. + :vartype dns_resource_references: + list[~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReference] + """ + + _attribute_map = { + "dns_resource_references": {"key": "properties.dnsResourceReferences", "type": "[DnsResourceReference]"}, + } + + def __init__( + self, *, dns_resource_references: Optional[List["_models.DnsResourceReference"]] = None, **kwargs: Any + ) -> None: + """ + :keyword dns_resource_references: The result of dns resource reference request. A list of dns + resource references for each of the azure resource in the request. + :paramtype dns_resource_references: + list[~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReference] + """ + super().__init__(**kwargs) + self.dns_resource_references = dns_resource_references + + +class DnssecConfig(_serialization.Model): + """Represents the DNSSEC configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the DNSSEC configuration. + :vartype id: str + :ivar name: The name of the DNSSEC configuration. + :vartype name: str + :ivar type: The type of the DNSSEC configuration. + :vartype type: str + :ivar etag: The etag of the DNSSEC configuration. + :vartype etag: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dns.v2023_07_01_preview.models.SystemData + :ivar provisioning_state: Provisioning State of the DNSSEC configuration. + :vartype provisioning_state: str + :ivar signing_keys: The list of signing keys. + :vartype signing_keys: list[~azure.mgmt.dns.v2023_07_01_preview.models.SigningKey] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "signing_keys": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "signing_keys": {"key": "properties.signingKeys", "type": "[SigningKey]"}, + } + + def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword etag: The etag of the DNSSEC configuration. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.etag = etag + self.system_data = None + self.provisioning_state = None + self.signing_keys = None + + +class DnssecConfigListResult(_serialization.Model): + """The response to a List DNSSEC configurations operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Information about the DNSSEC configurations in the response. + :vartype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] + :ivar next_link: The continuation token for the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DnssecConfig]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DnssecConfig"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Information about the DNSSEC configurations in the response. + :paramtype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.DnssecConfig] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class DsRecord(_serialization.Model): + """A DS record. For more information about the DS record format, see RFC 4034: + https://www.rfc-editor.org/rfc/rfc4034. + + :ivar key_tag: The key tag value is used to determine which DNSKEY Resource Record is used for + signature verification. + :vartype key_tag: int + :ivar algorithm: The security algorithm type represents the standard security algorithm number + of the DNSKEY Resource Record. See: + https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml. + :vartype algorithm: int + :ivar digest: The digest entity. + :vartype digest: ~azure.mgmt.dns.v2023_07_01_preview.models.Digest + """ + + _attribute_map = { + "key_tag": {"key": "keyTag", "type": "int"}, + "algorithm": {"key": "algorithm", "type": "int"}, + "digest": {"key": "digest", "type": "Digest"}, + } + + def __init__( + self, + *, + key_tag: Optional[int] = None, + algorithm: Optional[int] = None, + digest: Optional["_models.Digest"] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_tag: The key tag value is used to determine which DNSKEY Resource Record is used + for signature verification. + :paramtype key_tag: int + :keyword algorithm: The security algorithm type represents the standard security algorithm + number of the DNSKEY Resource Record. See: + https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml. + :paramtype algorithm: int + :keyword digest: The digest entity. + :paramtype digest: ~azure.mgmt.dns.v2023_07_01_preview.models.Digest + """ + super().__init__(**kwargs) + self.key_tag = key_tag + self.algorithm = algorithm + self.digest = digest + + +class MxRecord(_serialization.Model): + """An MX record. + + :ivar preference: The preference value for this MX record. + :vartype preference: int + :ivar exchange: The domain name of the mail host for this MX record. + :vartype exchange: str + """ + + _attribute_map = { + "preference": {"key": "preference", "type": "int"}, + "exchange": {"key": "exchange", "type": "str"}, + } + + def __init__(self, *, preference: Optional[int] = None, exchange: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword preference: The preference value for this MX record. + :paramtype preference: int + :keyword exchange: The domain name of the mail host for this MX record. + :paramtype exchange: str + """ + super().__init__(**kwargs) + self.preference = preference + self.exchange = exchange + + +class NaptrRecord(_serialization.Model): + """A NAPTR record. For more information about the NAPTR record format, see RFC 3403: + https://www.rfc-editor.org/rfc/rfc3403. + + :ivar order: The order in which the NAPTR records MUST be processed in order to accurately + represent the ordered list of rules. The ordering is from lowest to highest. Valid values: + 0-65535. + :vartype order: int + :ivar preference: The preference specifies the order in which NAPTR records with equal 'order' + values should be processed, low numbers being processed before high numbers. Valid values: + 0-65535. + :vartype preference: int + :ivar flags: The flags specific to DDDS applications. Values currently defined in RFC 3404 are + uppercase and lowercase letters "A", "P", "S", and "U", and the empty string, "". Enclose Flags + in quotation marks. + :vartype flags: str + :ivar services: The services specific to DDDS applications. Enclose Services in quotation + marks. + :vartype services: str + :ivar regexp: The regular expression that the DDDS application uses to convert an input value + into an output value. For example: an IP phone system might use a regular expression to convert + a phone number that is entered by a user into a SIP URI. Enclose the regular expression in + quotation marks. Specify either a value for 'regexp' or a value for 'replacement'. + :vartype regexp: str + :ivar replacement: The replacement is a fully qualified domain name (FQDN) of the next domain + name that you want the DDDS application to submit a DNS query for. The DDDS application + replaces the input value with the value specified for replacement. Specify either a value for + 'regexp' or a value for 'replacement'. If you specify a value for 'regexp', specify a dot (.) + for 'replacement'. + :vartype replacement: str + """ + + _attribute_map = { + "order": {"key": "order", "type": "int"}, + "preference": {"key": "preference", "type": "int"}, + "flags": {"key": "flags", "type": "str"}, + "services": {"key": "services", "type": "str"}, + "regexp": {"key": "regexp", "type": "str"}, + "replacement": {"key": "replacement", "type": "str"}, + } + + def __init__( + self, + *, + order: Optional[int] = None, + preference: Optional[int] = None, + flags: Optional[str] = None, + services: Optional[str] = None, + regexp: Optional[str] = None, + replacement: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword order: The order in which the NAPTR records MUST be processed in order to accurately + represent the ordered list of rules. The ordering is from lowest to highest. Valid values: + 0-65535. + :paramtype order: int + :keyword preference: The preference specifies the order in which NAPTR records with equal + 'order' values should be processed, low numbers being processed before high numbers. Valid + values: 0-65535. + :paramtype preference: int + :keyword flags: The flags specific to DDDS applications. Values currently defined in RFC 3404 + are uppercase and lowercase letters "A", "P", "S", and "U", and the empty string, "". Enclose + Flags in quotation marks. + :paramtype flags: str + :keyword services: The services specific to DDDS applications. Enclose Services in quotation + marks. + :paramtype services: str + :keyword regexp: The regular expression that the DDDS application uses to convert an input + value into an output value. For example: an IP phone system might use a regular expression to + convert a phone number that is entered by a user into a SIP URI. Enclose the regular expression + in quotation marks. Specify either a value for 'regexp' or a value for 'replacement'. + :paramtype regexp: str + :keyword replacement: The replacement is a fully qualified domain name (FQDN) of the next + domain name that you want the DDDS application to submit a DNS query for. The DDDS application + replaces the input value with the value specified for replacement. Specify either a value for + 'regexp' or a value for 'replacement'. If you specify a value for 'regexp', specify a dot (.) + for 'replacement'. + :paramtype replacement: str + """ + super().__init__(**kwargs) + self.order = order + self.preference = preference + self.flags = flags + self.services = services + self.regexp = regexp + self.replacement = replacement + + +class NsRecord(_serialization.Model): + """An NS record. + + :ivar nsdname: The name server name for this NS record. + :vartype nsdname: str + """ + + _attribute_map = { + "nsdname": {"key": "nsdname", "type": "str"}, + } + + def __init__(self, *, nsdname: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword nsdname: The name server name for this NS record. + :paramtype nsdname: str + """ + super().__init__(**kwargs) + self.nsdname = nsdname + + +class PtrRecord(_serialization.Model): + """A PTR record. + + :ivar ptrdname: The PTR target domain name for this PTR record. + :vartype ptrdname: str + """ + + _attribute_map = { + "ptrdname": {"key": "ptrdname", "type": "str"}, + } + + def __init__(self, *, ptrdname: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ptrdname: The PTR target domain name for this PTR record. + :paramtype ptrdname: str + """ + super().__init__(**kwargs) + self.ptrdname = ptrdname + + +class RecordSet(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Describes a DNS record set (a collection of DNS records with the same name and type). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the record set. + :vartype id: str + :ivar name: The name of the record set. + :vartype name: str + :ivar type: The type of the record set. + :vartype type: str + :ivar etag: The etag of the record set. + :vartype etag: str + :ivar metadata: The metadata attached to the record set. + :vartype metadata: dict[str, str] + :ivar ttl: The TTL (time-to-live) of the records in the record set. + :vartype ttl: int + :ivar fqdn: Fully qualified domain name of the record set. + :vartype fqdn: str + :ivar provisioning_state: provisioning State of the record set. + :vartype provisioning_state: str + :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 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. + :vartype aaaa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.AaaaRecord] + :ivar mx_records: The list of MX records in the record set. + :vartype mx_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.MxRecord] + :ivar ns_records: The list of NS records in the record set. + :vartype ns_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.NsRecord] + :ivar ptr_records: The list of PTR records in the record set. + :vartype ptr_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.PtrRecord] + :ivar srv_records: The list of SRV records in the record set. + :vartype srv_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.SrvRecord] + :ivar txt_records: The list of TXT records in the record set. + :vartype txt_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.TxtRecord] + :ivar cname_record: The CNAME record in the record set. + :vartype cname_record: ~azure.mgmt.dns.v2023_07_01_preview.models.CnameRecord + :ivar soa_record: The SOA record in the record set. + :vartype soa_record: ~azure.mgmt.dns.v2023_07_01_preview.models.SoaRecord + :ivar caa_records: The list of CAA records in the record set. + :vartype caa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.CaaRecord] + :ivar ds_records: The list of DS records in the record set. + :vartype ds_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.DsRecord] + :ivar tlsa_records: The list of TLSA records in the record set. + :vartype tlsa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.TlsaRecord] + :ivar naptr_records: The list of NAPTR records in the record set. + :vartype naptr_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.NaptrRecord] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "fqdn": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "ttl": {"key": "properties.TTL", "type": "int"}, + "fqdn": {"key": "properties.fqdn", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "target_resource": {"key": "properties.targetResource", "type": "SubResource"}, + "a_records": {"key": "properties.ARecords", "type": "[ARecord]"}, + "aaaa_records": {"key": "properties.AAAARecords", "type": "[AaaaRecord]"}, + "mx_records": {"key": "properties.MXRecords", "type": "[MxRecord]"}, + "ns_records": {"key": "properties.NSRecords", "type": "[NsRecord]"}, + "ptr_records": {"key": "properties.PTRRecords", "type": "[PtrRecord]"}, + "srv_records": {"key": "properties.SRVRecords", "type": "[SrvRecord]"}, + "txt_records": {"key": "properties.TXTRecords", "type": "[TxtRecord]"}, + "cname_record": {"key": "properties.CNAMERecord", "type": "CnameRecord"}, + "soa_record": {"key": "properties.SOARecord", "type": "SoaRecord"}, + "caa_records": {"key": "properties.caaRecords", "type": "[CaaRecord]"}, + "ds_records": {"key": "properties.DSRecords", "type": "[DsRecord]"}, + "tlsa_records": {"key": "properties.TLSARecords", "type": "[TlsaRecord]"}, + "naptr_records": {"key": "properties.NAPTRRecords", "type": "[NaptrRecord]"}, + } + + def __init__( + self, + *, + etag: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + ttl: Optional[int] = None, + target_resource: 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, + ns_records: Optional[List["_models.NsRecord"]] = None, + ptr_records: Optional[List["_models.PtrRecord"]] = None, + srv_records: Optional[List["_models.SrvRecord"]] = None, + txt_records: Optional[List["_models.TxtRecord"]] = None, + cname_record: Optional["_models.CnameRecord"] = None, + soa_record: Optional["_models.SoaRecord"] = None, + caa_records: Optional[List["_models.CaaRecord"]] = None, + ds_records: Optional[List["_models.DsRecord"]] = None, + tlsa_records: Optional[List["_models.TlsaRecord"]] = None, + naptr_records: Optional[List["_models.NaptrRecord"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword etag: The etag of the record set. + :paramtype etag: str + :keyword metadata: The metadata attached to the record set. + :paramtype metadata: dict[str, str] + :keyword ttl: The TTL (time-to-live) of the records in the record set. + :paramtype ttl: int + :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 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. + :paramtype aaaa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.AaaaRecord] + :keyword mx_records: The list of MX records in the record set. + :paramtype mx_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.MxRecord] + :keyword ns_records: The list of NS records in the record set. + :paramtype ns_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.NsRecord] + :keyword ptr_records: The list of PTR records in the record set. + :paramtype ptr_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.PtrRecord] + :keyword srv_records: The list of SRV records in the record set. + :paramtype srv_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.SrvRecord] + :keyword txt_records: The list of TXT records in the record set. + :paramtype txt_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.TxtRecord] + :keyword cname_record: The CNAME record in the record set. + :paramtype cname_record: ~azure.mgmt.dns.v2023_07_01_preview.models.CnameRecord + :keyword soa_record: The SOA record in the record set. + :paramtype soa_record: ~azure.mgmt.dns.v2023_07_01_preview.models.SoaRecord + :keyword caa_records: The list of CAA records in the record set. + :paramtype caa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.CaaRecord] + :keyword ds_records: The list of DS records in the record set. + :paramtype ds_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.DsRecord] + :keyword tlsa_records: The list of TLSA records in the record set. + :paramtype tlsa_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.TlsaRecord] + :keyword naptr_records: The list of NAPTR records in the record set. + :paramtype naptr_records: list[~azure.mgmt.dns.v2023_07_01_preview.models.NaptrRecord] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.etag = etag + self.metadata = metadata + self.ttl = ttl + self.fqdn = None + self.provisioning_state = None + self.target_resource = target_resource + self.a_records = a_records + self.aaaa_records = aaaa_records + self.mx_records = mx_records + self.ns_records = ns_records + self.ptr_records = ptr_records + self.srv_records = srv_records + self.txt_records = txt_records + self.cname_record = cname_record + self.soa_record = soa_record + self.caa_records = caa_records + self.ds_records = ds_records + self.tlsa_records = tlsa_records + self.naptr_records = naptr_records + + +class RecordSetListResult(_serialization.Model): + """The response to a record set List operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Information about the record sets in the response. + :vartype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] + :ivar next_link: The continuation token for the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RecordSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.RecordSet"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Information about the record sets in the response. + :paramtype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class RecordSetUpdateParameters(_serialization.Model): + """Parameters supplied to update a record set. + + :ivar record_set: Specifies information about the record set being updated. + :vartype record_set: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + """ + + _attribute_map = { + "record_set": {"key": "RecordSet", "type": "RecordSet"}, + } + + def __init__(self, *, record_set: Optional["_models.RecordSet"] = None, **kwargs: Any) -> None: + """ + :keyword record_set: Specifies information about the record set being updated. + :paramtype record_set: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + """ + super().__init__(**kwargs) + self.record_set = record_set + + +class Resource(_serialization.Model): + """Common properties of an Azure Resource Manager 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. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class SigningKey(_serialization.Model): + """Represents the signing key. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar delegation_signer_info: The delegation signer information. + :vartype delegation_signer_info: + list[~azure.mgmt.dns.v2023_07_01_preview.models.DelegationSignerInfo] + :ivar flags: The flags specifies how the key is used. + :vartype flags: int + :ivar key_tag: The key tag value of the DNSKEY Resource Record. + :vartype key_tag: int + :ivar protocol: The protocol value. The value is always 3. + :vartype protocol: int + :ivar public_key: The public key, represented as a Base64 encoding. + :vartype public_key: str + :ivar security_algorithm_type: The security algorithm type represents the standard security + algorithm number of the DNSKEY Resource Record. See: + https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml. + :vartype security_algorithm_type: int + """ + + _validation = { + "delegation_signer_info": {"readonly": True}, + "flags": {"readonly": True}, + "key_tag": {"readonly": True}, + "protocol": {"readonly": True}, + "public_key": {"readonly": True}, + "security_algorithm_type": {"readonly": True}, + } + + _attribute_map = { + "delegation_signer_info": {"key": "delegationSignerInfo", "type": "[DelegationSignerInfo]"}, + "flags": {"key": "flags", "type": "int"}, + "key_tag": {"key": "keyTag", "type": "int"}, + "protocol": {"key": "protocol", "type": "int"}, + "public_key": {"key": "publicKey", "type": "str"}, + "security_algorithm_type": {"key": "securityAlgorithmType", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.delegation_signer_info = None + self.flags = None + self.key_tag = None + self.protocol = None + self.public_key = None + self.security_algorithm_type = None + + +class SoaRecord(_serialization.Model): + """An SOA record. + + :ivar host: The domain name of the authoritative name server for this SOA record. + :vartype host: str + :ivar email: The email contact for this SOA record. + :vartype email: str + :ivar serial_number: The serial number for this SOA record. + :vartype serial_number: int + :ivar refresh_time: The refresh value for this SOA record. + :vartype refresh_time: int + :ivar retry_time: The retry time for this SOA record. + :vartype retry_time: int + :ivar expire_time: The expire time for this SOA record. + :vartype expire_time: int + :ivar minimum_ttl: The minimum value for this SOA record. By convention this is used to + determine the negative caching duration. + :vartype minimum_ttl: int + """ + + _attribute_map = { + "host": {"key": "host", "type": "str"}, + "email": {"key": "email", "type": "str"}, + "serial_number": {"key": "serialNumber", "type": "int"}, + "refresh_time": {"key": "refreshTime", "type": "int"}, + "retry_time": {"key": "retryTime", "type": "int"}, + "expire_time": {"key": "expireTime", "type": "int"}, + "minimum_ttl": {"key": "minimumTTL", "type": "int"}, + } + + def __init__( + self, + *, + host: Optional[str] = None, + email: Optional[str] = None, + serial_number: Optional[int] = None, + refresh_time: Optional[int] = None, + retry_time: Optional[int] = None, + expire_time: Optional[int] = None, + minimum_ttl: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword host: The domain name of the authoritative name server for this SOA record. + :paramtype host: str + :keyword email: The email contact for this SOA record. + :paramtype email: str + :keyword serial_number: The serial number for this SOA record. + :paramtype serial_number: int + :keyword refresh_time: The refresh value for this SOA record. + :paramtype refresh_time: int + :keyword retry_time: The retry time for this SOA record. + :paramtype retry_time: int + :keyword expire_time: The expire time for this SOA record. + :paramtype expire_time: int + :keyword minimum_ttl: The minimum value for this SOA record. By convention this is used to + determine the negative caching duration. + :paramtype minimum_ttl: int + """ + super().__init__(**kwargs) + self.host = host + self.email = email + self.serial_number = serial_number + self.refresh_time = refresh_time + self.retry_time = retry_time + self.expire_time = expire_time + self.minimum_ttl = minimum_ttl + + +class SrvRecord(_serialization.Model): + """An SRV record. + + :ivar priority: The priority value for this SRV record. + :vartype priority: int + :ivar weight: The weight value for this SRV record. + :vartype weight: int + :ivar port: The port value for this SRV record. + :vartype port: int + :ivar target: The target domain name for this SRV record. + :vartype target: str + """ + + _attribute_map = { + "priority": {"key": "priority", "type": "int"}, + "weight": {"key": "weight", "type": "int"}, + "port": {"key": "port", "type": "int"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__( + self, + *, + priority: Optional[int] = None, + weight: Optional[int] = None, + port: Optional[int] = None, + target: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword priority: The priority value for this SRV record. + :paramtype priority: int + :keyword weight: The weight value for this SRV record. + :paramtype weight: int + :keyword port: The port value for this SRV record. + :paramtype port: int + :keyword target: The target domain name for this SRV record. + :paramtype target: str + """ + super().__init__(**kwargs) + self.priority = priority + self.weight = weight + self.port = port + self.target = target + + +class SubResource(_serialization.Model): + """A reference to a another resource. + + :ivar id: Resource Id. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource Id. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.dns.v2023_07_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TlsaRecord(_serialization.Model): + """A TLSA record. For more information about the TLSA record format, see RFC 6698: + https://www.rfc-editor.org/rfc/rfc6698. + + :ivar usage: The usage specifies the provided association that will be used to match the + certificate presented in the TLS handshake. + :vartype usage: int + :ivar selector: The selector specifies which part of the TLS certificate presented by the + server will be matched against the association data. + :vartype selector: int + :ivar matching_type: The matching type specifies how the certificate association is presented. + :vartype matching_type: int + :ivar cert_association_data: This specifies the certificate association data to be matched. + :vartype cert_association_data: str + """ + + _attribute_map = { + "usage": {"key": "usage", "type": "int"}, + "selector": {"key": "selector", "type": "int"}, + "matching_type": {"key": "matchingType", "type": "int"}, + "cert_association_data": {"key": "certAssociationData", "type": "str"}, + } + + def __init__( + self, + *, + usage: Optional[int] = None, + selector: Optional[int] = None, + matching_type: Optional[int] = None, + cert_association_data: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword usage: The usage specifies the provided association that will be used to match the + certificate presented in the TLS handshake. + :paramtype usage: int + :keyword selector: The selector specifies which part of the TLS certificate presented by the + server will be matched against the association data. + :paramtype selector: int + :keyword matching_type: The matching type specifies how the certificate association is + presented. + :paramtype matching_type: int + :keyword cert_association_data: This specifies the certificate association data to be matched. + :paramtype cert_association_data: str + """ + super().__init__(**kwargs) + self.usage = usage + self.selector = selector + self.matching_type = matching_type + self.cert_association_data = cert_association_data + + +class TxtRecord(_serialization.Model): + """A TXT record. + + :ivar value: The text value of this TXT record. + :vartype value: list[str] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[str]"}, + } + + def __init__(self, *, value: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword value: The text value of this TXT record. + :paramtype value: list[str] + """ + super().__init__(**kwargs) + self.value = value + + +class Zone(Resource): # pylint: disable=too-many-instance-attributes + """Describes a DNS zone. + + 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. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar etag: The etag of the zone. + :vartype etag: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.dns.v2023_07_01_preview.models.SystemData + :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this + DNS zone. This is a read-only property and any attempt to set this value will be ignored. + :vartype max_number_of_record_sets: int + :ivar max_number_of_records_per_record_set: The maximum number of records per record set that + can be created in this DNS zone. This is a read-only property and any attempt to set this + value will be ignored. + :vartype max_number_of_records_per_record_set: int + :ivar number_of_record_sets: The current number of record sets in this DNS zone. This is a + read-only property and any attempt to set this value will be ignored. + :vartype number_of_record_sets: int + :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any + attempt to set this value will be ignored. + :vartype name_servers: list[str] + :ivar zone_type: The type of this DNS zone (Public or Private). Known values are: "Public" and + "Private". + :vartype zone_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneType + :ivar registration_virtual_networks: A list of references to virtual networks that register + hostnames in this DNS zone. This is a only when ZoneType is Private. + :vartype registration_virtual_networks: + list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + :ivar resolution_virtual_networks: A list of references to virtual networks that resolve + records in this DNS zone. This is a only when ZoneType is Private. + :vartype resolution_virtual_networks: + list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + :ivar signing_keys: The list of signing keys. + :vartype signing_keys: list[~azure.mgmt.dns.v2023_07_01_preview.models.SigningKey] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "max_number_of_record_sets": {"readonly": True}, + "max_number_of_records_per_record_set": {"readonly": True}, + "number_of_record_sets": {"readonly": True}, + "name_servers": {"readonly": True}, + "signing_keys": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "max_number_of_record_sets": {"key": "properties.maxNumberOfRecordSets", "type": "int"}, + "max_number_of_records_per_record_set": {"key": "properties.maxNumberOfRecordsPerRecordSet", "type": "int"}, + "number_of_record_sets": {"key": "properties.numberOfRecordSets", "type": "int"}, + "name_servers": {"key": "properties.nameServers", "type": "[str]"}, + "zone_type": {"key": "properties.zoneType", "type": "str"}, + "registration_virtual_networks": {"key": "properties.registrationVirtualNetworks", "type": "[SubResource]"}, + "resolution_virtual_networks": {"key": "properties.resolutionVirtualNetworks", "type": "[SubResource]"}, + "signing_keys": {"key": "properties.signingKeys", "type": "[SigningKey]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + zone_type: Union[str, "_models.ZoneType"] = "Public", + registration_virtual_networks: Optional[List["_models.SubResource"]] = None, + resolution_virtual_networks: Optional[List["_models.SubResource"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword etag: The etag of the zone. + :paramtype etag: str + :keyword zone_type: The type of this DNS zone (Public or Private). Known values are: "Public" + and "Private". + :paramtype zone_type: str or ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneType + :keyword registration_virtual_networks: A list of references to virtual networks that register + hostnames in this DNS zone. This is a only when ZoneType is Private. + :paramtype registration_virtual_networks: + list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + :keyword resolution_virtual_networks: A list of references to virtual networks that resolve + records in this DNS zone. This is a only when ZoneType is Private. + :paramtype resolution_virtual_networks: + list[~azure.mgmt.dns.v2023_07_01_preview.models.SubResource] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.etag = etag + self.system_data = None + self.max_number_of_record_sets = None + self.max_number_of_records_per_record_set = None + self.number_of_record_sets = None + self.name_servers = None + self.zone_type = zone_type + self.registration_virtual_networks = registration_virtual_networks + self.resolution_virtual_networks = resolution_virtual_networks + self.signing_keys = None + + +class ZoneListResult(_serialization.Model): + """The response to a Zone List or ListAll operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Information about the DNS zones. + :vartype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] + :ivar next_link: The continuation token for the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Zone]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Zone"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Information about the DNS zones. + :paramtype value: list[~azure.mgmt.dns.v2023_07_01_preview.models.Zone] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ZoneUpdate(_serialization.Model): + """Describes a request to update a DNS zone. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/__init__.py new file mode 100644 index 000000000000..62aaadd3c149 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dnssec_configs_operations import DnssecConfigsOperations +from ._record_sets_operations import RecordSetsOperations +from ._zones_operations import ZonesOperations +from ._dns_resource_reference_operations import DnsResourceReferenceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DnssecConfigsOperations", + "RecordSetsOperations", + "ZonesOperations", + "DnsResourceReferenceOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() 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 new file mode 100644 index 000000000000..c22fb799ed83 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dns_resource_reference_operations.py @@ -0,0 +1,193 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_by_target_resources_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnsResourceReferenceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.DnsManagementClient`'s + :attr:`dns_resource_reference` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def get_by_target_resources( + self, parameters: _models.DnsResourceReferenceRequest, *, 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: ~azure.mgmt.dns.v2023_07_01_preview.models.DnsResourceReferenceRequest + :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: + """ + + @overload + def get_by_target_resources( + self, parameters: IO, *, 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 + :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: + """ + + @distributed_trace + def get_by_target_resources( + self, parameters: Union[_models.DnsResourceReferenceRequest, IO], **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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResourceReferenceResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DnsResourceReferenceRequest") + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResourceReferenceResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_target_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference" + } 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 new file mode 100644 index 000000000000..e1d309f338ac --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_dnssec_configs_operations.py @@ -0,0 +1,622 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, zone_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, zone_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_dns_zone_request( + resource_group_name: str, zone_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnssecConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.DnsManagementClient`'s + :attr:`dnssec_configs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DnssecConfig: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnssecConfig]: + """Creates or updates the DNSSEC configuration on a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of the DNSSEC configuration. Omit this value to always overwrite the + DNSSEC configuration. Specify the last-seen etag value to prevent accidentally overwriting any + concurrent changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow this DNSSEC configuration to be created, but to + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnssecConfig", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the DNSSEC configuration on a DNS zone. This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of this DNSSEC configuration. Omit this value to always delete the + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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" + } + + @distributed_trace + def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.DnssecConfig: + """Gets the DNSSEC configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfig] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnssecConfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/dnssecConfigs/default" + } + + @distributed_trace + def list_by_dns_zone( + self, resource_group_name: str, zone_name: str, **kwargs: Any + ) -> Iterable["_models.DnssecConfig"]: + """Lists the DNSSEC configurations in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.DnssecConfigListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnssecConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 new file mode 100644 index 000000000000..a1e5f2bae95a --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_record_sets_operations.py @@ -0,0 +1,1242 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "relativeRecordSetName": _SERIALIZER.url( + "relative_record_set_name", relative_record_set_name, "str", skip_quote=True + ), + "recordType": _SERIALIZER.url("record_type", record_type, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "relativeRecordSetName": _SERIALIZER.url( + "relative_record_set_name", relative_record_set_name, "str", skip_quote=True + ), + "recordType": _SERIALIZER.url("record_type", record_type, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "relativeRecordSetName": _SERIALIZER.url( + "relative_record_set_name", relative_record_set_name, "str", skip_quote=True + ), + "recordType": _SERIALIZER.url("record_type", record_type, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "relativeRecordSetName": _SERIALIZER.url( + "relative_record_set_name", relative_record_set_name, "str", skip_quote=True + ), + "recordType": _SERIALIZER.url("record_type", record_type, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_type_request( + resource_group_name: str, + zone_name: str, + record_type: Union[str, _models.RecordType], + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "recordType": _SERIALIZER.url("record_type", record_type, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if recordsetnamesuffix is not None: + _params["$recordsetnamesuffix"] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if recordsetnamesuffix is not None: + _params["$recordsetnamesuffix"] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_all_by_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if record_set_name_suffix is not None: + _params["$recordsetnamesuffix"] = _SERIALIZER.query("record_set_name_suffix", record_set_name_suffix, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RecordSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.DnsManagementClient`'s + :attr:`record_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: _models.RecordSet, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + :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. 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: + """ + + @overload + def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO + :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. 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: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: Union[_models.RecordSet, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.RecordSet: + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecordSet") + + request = build_update_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, + if_match=if_match, + api_version=api_version, + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecordSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: _models.RecordSet, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dns.v2023_07_01_preview.models.RecordSet + :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. + :type if_match: str + :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. 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :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. + :type if_match: str + :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. 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: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + parameters: Union[_models.RecordSet, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.RecordSet: + """Creates or updates a record set within a DNS zone. Record sets of type SOA can be updated but + not created (they are created when the DNS zone is created). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :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 + :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. + :type if_match: str + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecordSet") + + request = build_create_or_update_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, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a record set from a DNS zone. This operation cannot be undone. Record sets of type SOA + cannot be deleted (they are deleted when the DNS zone is deleted). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 + :param if_match: The etag of the record set. Omit this value to always delete the current + 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_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, + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, _models.RecordType], + **kwargs: Any + ) -> _models.RecordSet: + """Gets a record set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + Required. + :type relative_record_set_name: str + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSet] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecordSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" + } + + @distributed_trace + def list_by_type( + self, + resource_group_name: str, + zone_name: str, + record_type: Union[str, _models.RecordType], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSet"]: + """Lists the record sets of a specified type in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :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 + :param recordsetnamesuffix: The suffix label of the record set name that has to be used to + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSet"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :param recordsetnamesuffix: The suffix label of the record set name that has to be used to + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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" + } + + @distributed_trace + def list_all_by_dns_zone( + self, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSet"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :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 + :param record_set_name_suffix: The suffix label of the record set name that has to be used to + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.RecordSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RecordSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 new file mode 100644 index 000000000000..56ef79a01d20 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/operations/_zones_operations.py @@ -0,0 +1,964 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, zone_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, zone_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, zone_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "zoneName": _SERIALIZER.url("zone_name", zone_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ZonesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dns.v2023_07_01_preview.DnsManagementClient`'s + :attr:`zones` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: _models.Zone, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: ~azure.mgmt.dns.v2023_07_01_preview.models.Zone + :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 + :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. 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :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. 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: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: Union[_models.Zone, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> _models.Zone: + """Creates or updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Zone") + + 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, + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + 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 + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). Required. + :type zone_name: str + :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. + 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.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}" + } + + @distributed_trace + def get(self, resource_group_name: str, zone_name: str, **kwargs: Any) -> _models.Zone: + """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Zone", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @overload + def update( + self, + resource_group_name: str, + zone_name: str, + parameters: _models.ZoneUpdate, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: ~azure.mgmt.dns.v2023_07_01_preview.models.ZoneUpdate + :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. 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: + """ + + @overload + def update( + self, + resource_group_name: str, + zone_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. 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: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + zone_name: str, + parameters: Union[_models.ZoneUpdate, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.Zone: + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Zone] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ZoneUpdate") + + request = build_update_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, + 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) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Zone", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.Zone"]: + """Lists the DNS zones within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ZoneListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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. + + :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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + cls: ClsType[_models.ZoneListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ZoneListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/py.typed b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2023_07_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 c11e21ceaa8b..6bd27f988c9d 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 @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="zone1", relative_record_set_name="record1", record_type="AAAA", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteAAAARecordset.json 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 34827e1b4904..cfff26839fce 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_arecordset.py @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="zone1", relative_record_set_name="record1", record_type="A", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json 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 55090957aca5..10d27f10b046 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 @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="zone1", relative_record_set_name="record1", record_type="CAA", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteCaaRecordset.json 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 8e4ce27f33be..25afc099cb78 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 @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="0.0.127.in-addr.arpa", relative_record_set_name="1", record_type="PTR", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeletePTRRecordset.json 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 9a339769eaa8..bba2191c1ac5 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 @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="zone1", relative_record_set_name="record1", record_type="SRV", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteSRVRecordset.json 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 cc43cc8859c9..4f64c1b1ee5b 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 @@ -29,13 +29,12 @@ def main(): subscription_id="subid", ) - response = client.record_sets.delete( + client.record_sets.delete( resource_group_name="rg1", zone_name="zone1", relative_record_set_name="record1", record_type="TXT", ) - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteTXTRecordset.json 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 6f272eb59fe1..c6415f59e60c 100644 --- a/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py +++ b/sdk/network/azure-mgmt-dns/generated_samples/delete_zone.py @@ -29,11 +29,10 @@ def main(): subscription_id="subid", ) - response = client.zones.begin_delete( + client.zones.begin_delete( resource_group_name="rg1", zone_name="zone1", ).result() - print(response) # x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json