diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md b/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md index cb4949e2262a..66d16bea5b00 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md @@ -1,5 +1,38 @@ # Release History +## 1.1.0b2 (2024-XX-XX) + +### Features Added + + - Client `DnsResolverManagementClient` added operation group `dns_resolver_policies` + - Client `DnsResolverManagementClient` added operation group `dns_security_rules` + - Client `DnsResolverManagementClient` added operation group `dns_resolver_policy_virtual_network_links` + - Client `DnsResolverManagementClient` added operation group `dns_resolver_domain_lists` + - Model `Resource` added property `system_data` + - Added enum `ActionType` + - Added enum `BlockResponseCode` + - Added model `DnsResolverDomainList` + - Added model `DnsResolverDomainListPatch` + - Added model `DnsResolverDomainListResult` + - Added model `DnsResolverPolicy` + - Added model `DnsResolverPolicyListResult` + - Added model `DnsResolverPolicyPatch` + - Added model `DnsResolverPolicyVirtualNetworkLink` + - Added model `DnsResolverPolicyVirtualNetworkLinkListResult` + - Added model `DnsResolverPolicyVirtualNetworkLinkPatch` + - Added model `DnsSecurityRule` + - Added model `DnsSecurityRuleAction` + - Added model `DnsSecurityRuleListResult` + - Added model `DnsSecurityRulePatch` + - Added enum `DnsSecurityRuleState` + - Added model `ErrorAdditionalInfo` + - Added model `ErrorDetail` + - Added model `ErrorResponse` + - Added model `DnsResolverDomainListsOperations` + - Added model `DnsResolverPoliciesOperations` + - Added model `DnsResolverPolicyVirtualNetworkLinksOperations` + - Added model `DnsSecurityRulesOperations` + ## 1.1.0b1 (2022-12-27) ### Other Changes diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md b/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md index 3b9b2639b5ab..0a06e09239a6 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Dnsresolver Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -28,7 +28,7 @@ By default, [Azure Active Directory](https://aka.ms/awps/aad) token authenticati - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. -- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. +- `AZURE_CLIENT_SECRET` for Azure client secret. In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. @@ -36,17 +36,18 @@ With above configuration, client can be authenticated by following code: ```python from azure.identity import DefaultAzureCredential -from azure.mgmt.dnsresolver import DnsResolverManagementClient +from azure.mgmt.dnsresolver import DnsresolverManagementClient import os sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") -client = DnsResolverManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id) +client = DnsresolverManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id) ``` ## Examples - -Code samples for this package can be found at [Dnsresolver Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +Code samples for this package can be found at: +- [Search Dnsresolver Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) ## Troubleshooting @@ -58,6 +59,3 @@ Code samples for this package can be found at [Dnsresolver Management](https://d If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-dnsresolver%2FREADME.png) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json b/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json index d0601e795982..e4e710ae18e7 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json @@ -1,11 +1,11 @@ { - "commit": "89a9bf17524904e7670f0fd2d62ac882ca00d85c", + "commit": "15b16d1b5c3cccdecdd1cfe936f6a8005680c557", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.2.7", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/dnsresolver/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.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/dnsresolver/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/dnsresolver/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py index b9cfaaa0cab8..910a9b8d85eb 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py @@ -6,26 +6,19 @@ # 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 from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy 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 -class DnsResolverManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsResolverManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsResolverManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,16 +26,15 @@ class DnsResolverManagementClientConfiguration(Configuration): # pylint: disabl :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this - default value may result in unsupported behavior. + :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(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", "2022-07-01") + api_version: str = kwargs.pop("api_version", "2023-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dnsresolver/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py index 126ca0db9a59..d3d483b1e837 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py @@ -8,16 +8,23 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import DnsResolverManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( DnsForwardingRulesetsOperations, + DnsResolverDomainListsOperations, + DnsResolverPoliciesOperations, + DnsResolverPolicyVirtualNetworkLinksOperations, DnsResolversOperations, + DnsSecurityRulesOperations, ForwardingRulesOperations, InboundEndpointsOperations, OutboundEndpointsOperations, @@ -29,8 +36,8 @@ from azure.core.credentials import TokenCredential -class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version-keyword - """The DNS Resolver Management Client. +class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """DNS Resolver Client. :ivar dns_resolvers: DnsResolversOperations operations :vartype dns_resolvers: azure.mgmt.dnsresolver.operations.DnsResolversOperations @@ -45,14 +52,25 @@ class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version :vartype forwarding_rules: azure.mgmt.dnsresolver.operations.ForwardingRulesOperations :ivar virtual_network_links: VirtualNetworkLinksOperations operations :vartype virtual_network_links: azure.mgmt.dnsresolver.operations.VirtualNetworkLinksOperations + :ivar dns_resolver_policies: DnsResolverPoliciesOperations operations + :vartype dns_resolver_policies: azure.mgmt.dnsresolver.operations.DnsResolverPoliciesOperations + :ivar dns_security_rules: DnsSecurityRulesOperations operations + :vartype dns_security_rules: azure.mgmt.dnsresolver.operations.DnsSecurityRulesOperations + :ivar dns_resolver_policy_virtual_network_links: DnsResolverPolicyVirtualNetworkLinksOperations + operations + :vartype dns_resolver_policy_virtual_network_links: + azure.mgmt.dnsresolver.operations.DnsResolverPolicyVirtualNetworkLinksOperations + :ivar dns_resolver_domain_lists: DnsResolverDomainListsOperations operations + :vartype dns_resolver_domain_lists: + azure.mgmt.dnsresolver.operations.DnsResolverDomainListsOperations :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2022-07-01". Note that overriding this - default value may result in unsupported behavior. + :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. @@ -68,7 +86,25 @@ def __init__( self._config = DnsResolverManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -90,8 +126,20 @@ def __init__( self.virtual_network_links = VirtualNetworkLinksOperations( self._client, self._config, self._serialize, self._deserialize ) + self.dns_resolver_policies = DnsResolverPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_security_rules = DnsSecurityRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_resolver_policy_virtual_network_links = DnsResolverPolicyVirtualNetworkLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_resolver_domain_lists = DnsResolverDomainListsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -111,14 +159,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DnsResolverManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_serialization.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_serialization.py index 2c170e28dbca..8139854b97bb 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_serialization.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_serialization.py @@ -38,7 +38,22 @@ import re import sys import codecs -from typing import Optional, Union, AnyStr, IO, Mapping +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore @@ -48,12 +63,14 @@ import isodate # type: ignore -from typing import Dict, Any, cast - -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -107,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -126,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -277,8 +289,8 @@ class Model(object): _attribute_map: Dict[str, Dict[str, Any]] = {} _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -287,25 +299,25 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: cls._xml_map # type: ignore except AttributeError: @@ -322,8 +334,8 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): - """Return the JSON that would be sent to azure from this model. + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -334,10 +346,15 @@ def serialize(self, keep_readonly=False, **kwargs): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -368,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -384,7 +401,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -393,10 +410,15 @@ def deserialize(cls, data, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -409,8 +431,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -418,7 +440,7 @@ def from_dict(cls, data, key_extractors=None, content_type=None): if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -518,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,7 +556,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -602,7 +624,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): @@ -622,12 +644,11 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore - unflattened = {k: new_attr} - new_attr = unflattened + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized @@ -636,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -656,8 +678,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -683,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -703,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -715,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -723,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -777,6 +800,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is CoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -795,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -863,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -875,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -922,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -955,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1132,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1161,7 +1195,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1170,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1191,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1242,7 +1275,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 @@ -1266,7 +1299,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): @@ -1332,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1385,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1405,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1442,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1471,22 +1504,22 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1496,7 +1529,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: @@ -1539,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1613,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1661,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1718,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1769,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1823,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1854,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1871,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1906,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1943,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1959,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py deleted file mode 100644 index 9aad73fc743e..000000000000 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py +++ /dev/null @@ -1,27 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_version.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_version.py index 653b73a4a199..f1fb63697cf5 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_version.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b1" +VERSION = "1.1.0b2" diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py index a5a7cd9ecd93..7bc269fba764 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py @@ -6,26 +6,19 @@ # 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 from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy 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 -class DnsResolverManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DnsResolverManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DnsResolverManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,16 +26,15 @@ class DnsResolverManagementClientConfiguration(Configuration): # pylint: disabl :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this - default value may result in unsupported behavior. + :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(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", "2022-07-01") + api_version: str = kwargs.pop("api_version", "2023-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -54,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-dnsresolver/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -62,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py index 7be2b47d8a46..dd73065f084b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py @@ -8,16 +8,23 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import DnsResolverManagementClientConfiguration from .operations import ( DnsForwardingRulesetsOperations, + DnsResolverDomainListsOperations, + DnsResolverPoliciesOperations, + DnsResolverPolicyVirtualNetworkLinksOperations, DnsResolversOperations, + DnsSecurityRulesOperations, ForwardingRulesOperations, InboundEndpointsOperations, OutboundEndpointsOperations, @@ -29,8 +36,8 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version-keyword - """The DNS Resolver Management Client. +class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """DNS Resolver Client. :ivar dns_resolvers: DnsResolversOperations operations :vartype dns_resolvers: azure.mgmt.dnsresolver.aio.operations.DnsResolversOperations @@ -46,14 +53,26 @@ class DnsResolverManagementClient: # pylint: disable=client-accepts-api-version :ivar virtual_network_links: VirtualNetworkLinksOperations operations :vartype virtual_network_links: azure.mgmt.dnsresolver.aio.operations.VirtualNetworkLinksOperations + :ivar dns_resolver_policies: DnsResolverPoliciesOperations operations + :vartype dns_resolver_policies: + azure.mgmt.dnsresolver.aio.operations.DnsResolverPoliciesOperations + :ivar dns_security_rules: DnsSecurityRulesOperations operations + :vartype dns_security_rules: azure.mgmt.dnsresolver.aio.operations.DnsSecurityRulesOperations + :ivar dns_resolver_policy_virtual_network_links: DnsResolverPolicyVirtualNetworkLinksOperations + operations + :vartype dns_resolver_policy_virtual_network_links: + azure.mgmt.dnsresolver.aio.operations.DnsResolverPolicyVirtualNetworkLinksOperations + :ivar dns_resolver_domain_lists: DnsResolverDomainListsOperations operations + :vartype dns_resolver_domain_lists: + azure.mgmt.dnsresolver.aio.operations.DnsResolverDomainListsOperations :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. 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 "2022-07-01". Note that overriding this - default value may result in unsupported behavior. + :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. @@ -69,7 +88,25 @@ def __init__( self._config = DnsResolverManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -91,8 +128,22 @@ def __init__( self.virtual_network_links = VirtualNetworkLinksOperations( self._client, self._config, self._serialize, self._deserialize ) + self.dns_resolver_policies = DnsResolverPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_security_rules = DnsSecurityRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_resolver_policy_virtual_network_links = DnsResolverPolicyVirtualNetworkLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_resolver_domain_lists = DnsResolverDomainListsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -112,14 +163,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DnsResolverManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py index 231d09975ac1..b81ec42ea3c5 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py @@ -12,6 +12,10 @@ from ._dns_forwarding_rulesets_operations import DnsForwardingRulesetsOperations from ._forwarding_rules_operations import ForwardingRulesOperations from ._virtual_network_links_operations import VirtualNetworkLinksOperations +from ._dns_resolver_policies_operations import DnsResolverPoliciesOperations +from ._dns_security_rules_operations import DnsSecurityRulesOperations +from ._dns_resolver_policy_virtual_network_links_operations import DnsResolverPolicyVirtualNetworkLinksOperations +from ._dns_resolver_domain_lists_operations import DnsResolverDomainListsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -24,6 +28,10 @@ "DnsForwardingRulesetsOperations", "ForwardingRulesOperations", "VirtualNetworkLinksOperations", + "DnsResolverPoliciesOperations", + "DnsSecurityRulesOperations", + "DnsResolverPolicyVirtualNetworkLinksOperations", + "DnsResolverDomainListsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py index eb79ef3262e3..3559677d6ba8 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dns_forwarding_rulesets_operations import ( build_create_or_update_request, build_delete_request, @@ -41,10 +42,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +73,12 @@ async def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRuleset, IO], + parameters: Union[_models.DnsForwardingRuleset, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsForwardingRuleset]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +89,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsForwardingRuleset]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsForwardingRuleset") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, @@ -112,38 +111,33 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -176,14 +170,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -195,7 +181,7 @@ async def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -210,7 +196,7 @@ async def begin_create_or_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -221,14 +207,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -240,7 +218,7 @@ async def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRuleset, IO], + parameters: Union[_models.DnsForwardingRuleset, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -252,9 +230,9 @@ async def begin_create_or_update( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsForwardingRuleset type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -262,17 +240,6 @@ async def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -281,9 +248,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -303,12 +268,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -318,27 +284,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DnsForwardingRuleset].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/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return AsyncLROPoller[_models.DnsForwardingRuleset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRulesetPatch, IO], + parameters: Union[_models.DnsForwardingRulesetPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsForwardingRuleset]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,21 +313,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsForwardingRuleset]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsForwardingRulesetPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, @@ -372,35 +334,33 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -429,14 +389,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -448,7 +400,7 @@ async def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -462,7 +414,7 @@ async def begin_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -470,14 +422,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -489,7 +433,7 @@ async def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRulesetPatch, IO], + parameters: Union[_models.DnsForwardingRulesetPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.DnsForwardingRuleset]: @@ -500,24 +444,13 @@ async def begin_update( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + DnsForwardingRulesetPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -526,9 +459,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -547,12 +478,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -562,22 +494,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DnsForwardingRuleset].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return AsyncLROPoller[_models.DnsForwardingRuleset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,40 +518,42 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -639,14 +571,6 @@ async def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -654,15 +578,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, if_match=if_match, @@ -672,11 +594,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -685,17 +608,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -708,12 +627,11 @@ async def get( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -724,25 +642,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -751,16 +666,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -774,7 +685,6 @@ def list_by_resource_group( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsForwardingRuleset or the result of cls(response) :rtype: @@ -784,12 +694,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -800,17 +708,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -822,13 +728,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) @@ -838,10 +743,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,10 +759,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.DnsForwardingRuleset"]: """Lists DNS forwarding rulesets in all resource groups of a subscription. @@ -864,7 +766,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsForwardingRuleset or the result of cls(response) :rtype: @@ -874,12 +775,10 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -890,16 +789,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -911,13 +808,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) @@ -927,10 +823,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -942,8 +839,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets"} - @distributed_trace def list_by_virtual_network( self, resource_group_name: str, virtual_network_name: str, top: Optional[int] = None, **kwargs: Any @@ -958,7 +853,6 @@ def list_by_virtual_network( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 VirtualNetworkDnsForwardingRuleset or the result of cls(response) :rtype: @@ -968,12 +862,10 @@ def list_by_virtual_network( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkDnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -984,18 +876,16 @@ def list_by_virtual_network( def prepare_request(next_link=None): if not next_link: - request = build_list_by_virtual_network_request( + _request = build_list_by_virtual_network_request( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_virtual_network.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1007,13 +897,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkDnsForwardingRulesetListResult", pipeline_response) @@ -1023,10 +912,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1037,7 +927,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_domain_lists_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_domain_lists_operations.py new file mode 100644 index 000000000000..3a3b39be4556 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_domain_lists_operations.py @@ -0,0 +1,866 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._dns_resolver_domain_lists_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, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnsResolverDomainListsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_resolver_domain_lists` 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, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainList, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverDomainList") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: _models.DnsResolverDomainList, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainList, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverDomainList type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverDomainList] = 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, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverDomainList].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverDomainList]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainListPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverDomainListPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: _models.DnsResolverDomainListPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainListPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainListPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverDomainListPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainListPatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverDomainList or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverDomainList] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverDomainList].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverDomainList]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS resolver domain list. WARNING: 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 dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, dns_resolver_domain_list_name: str, **kwargs: Any + ) -> _models.DnsResolverDomainList: + """Gets properties of a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :return: DnsResolverDomainList or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainList] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DnsResolverDomainList"]: + """Lists DNS resolver domain lists 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 results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverDomainList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.DnsResolverDomainList"]: + """Lists DNS resolver domain lists in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverDomainList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policies_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policies_operations.py new file mode 100644 index 000000000000..8661a456fdfc --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policies_operations.py @@ -0,0 +1,935 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._dns_resolver_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_virtual_network_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnsResolverPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_resolver_policies` 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, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicy, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: _models.DnsResolverPolicy, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicy, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicy] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicyPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverPolicyPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: _models.DnsResolverPolicyPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicyPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverPolicyPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyPatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, dns_resolver_policy_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, dns_resolver_policy_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS resolver policy. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, dns_resolver_policy_name: str, **kwargs: Any + ) -> _models.DnsResolverPolicy: + """Gets properties of a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :return: DnsResolverPolicy or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DnsResolverPolicy"]: + """Lists DNS resolver policies 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 results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicy or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.DnsResolverPolicy"]: + """Lists DNS resolver policies in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicy or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_virtual_network( + self, resource_group_name: str, virtual_network_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SubResource"]: + """Lists DNS resolver policy resource IDs linked to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. Required. + :type virtual_network_name: str + :return: An iterator like instance of either SubResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.SubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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_virtual_network_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SubResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policy_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policy_virtual_network_links_operations.py new file mode 100644 index 000000000000..076c377e3022 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolver_policy_virtual_network_links_operations.py @@ -0,0 +1,834 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._dns_resolver_policy_virtual_network_links_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnsResolverPolicyVirtualNetworkLinksOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_resolver_policy_virtual_network_links` 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, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLink, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverPolicyVirtualNetworkLink") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: _models.DnsResolverPolicyVirtualNetworkLink, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLink, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverPolicyVirtualNetworkLink type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink or + IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLinkPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverPolicyVirtualNetworkLinkPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: _models.DnsResolverPolicyVirtualNetworkLinkPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLinkPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLinkPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverPolicyVirtualNetworkLinkPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLinkPatch or + IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either DnsResolverPolicyVirtualNetworkLink + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsResolverPolicyVirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS resolver policy virtual network link. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + **kwargs: Any + ) -> _models.DnsResolverPolicyVirtualNetworkLink: + """Gets properties of a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :return: DnsResolverPolicyVirtualNetworkLink or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, dns_resolver_policy_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DnsResolverPolicyVirtualNetworkLink"]: + """Lists DNS resolver policy virtual network links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicyVirtualNetworkLink or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLinkListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLinkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py index e737bd795ac2..3c6f7e43ac7a 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dns_resolvers_operations import ( build_create_or_update_request, build_delete_request, @@ -41,10 +42,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +73,12 @@ async def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolver, IO], + parameters: Union[_models.DnsResolver, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsResolver]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,21 +89,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsResolver]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolver") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, @@ -112,38 +111,33 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsResolver", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -176,14 +170,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -195,7 +181,7 @@ async def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -210,7 +196,7 @@ async def begin_create_or_update( :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -221,14 +207,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -240,7 +218,7 @@ async def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolver, IO], + parameters: Union[_models.DnsResolver, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -252,9 +230,9 @@ async def begin_create_or_update( :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a DnsResolver + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -262,17 +240,6 @@ async def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -281,9 +248,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -303,12 +268,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -318,27 +284,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DnsResolver].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/dnsResolvers/{dnsResolverName}" - } + return AsyncLROPoller[_models.DnsResolver]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolverPatch, IO], + parameters: Union[_models.DnsResolverPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsResolver]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -349,21 +313,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsResolver]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsResolverPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, @@ -372,35 +334,33 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -429,14 +389,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -448,7 +400,7 @@ async def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -462,7 +414,7 @@ async def begin_update( :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -470,14 +422,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -489,7 +433,7 @@ async def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolverPatch, IO], + parameters: Union[_models.DnsResolverPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.DnsResolver]: @@ -500,24 +444,13 @@ async def begin_update( :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a DnsResolverPatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -526,9 +459,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -547,12 +478,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -562,22 +494,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DnsResolver].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return AsyncLROPoller[_models.DnsResolver]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,40 +518,42 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -638,14 +570,6 @@ async def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -653,15 +577,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, if_match=if_match, @@ -671,11 +593,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -684,17 +607,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: Any) -> _models.DnsResolver: @@ -705,12 +624,11 @@ async def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResolver or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.DnsResolver :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -721,25 +639,22 @@ async def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -748,16 +663,12 @@ async def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -771,7 +682,6 @@ def list_by_resource_group( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsResolver or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolver] :raises ~azure.core.exceptions.HttpResponseError: @@ -779,12 +689,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolverListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,17 +703,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -817,13 +723,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DnsResolverListResult", pipeline_response) @@ -833,10 +738,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -848,10 +754,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.DnsResolver"]: """Lists DNS resolvers in all resource groups of a subscription. @@ -859,7 +761,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsResolver or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolver] :raises ~azure.core.exceptions.HttpResponseError: @@ -867,12 +768,10 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolverListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -883,16 +782,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_mode def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -904,13 +801,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DnsResolverListResult", pipeline_response) @@ -920,10 +816,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -935,8 +832,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers"} - @distributed_trace def list_by_virtual_network( self, resource_group_name: str, virtual_network_name: str, top: Optional[int] = None, **kwargs: Any @@ -951,7 +846,6 @@ def list_by_virtual_network( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 SubResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.SubResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -959,12 +853,10 @@ def list_by_virtual_network( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -975,18 +867,16 @@ def list_by_virtual_network( def prepare_request(next_link=None): if not next_link: - request = build_list_by_virtual_network_request( + _request = build_list_by_virtual_network_request( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_virtual_network.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -998,13 +888,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SubResourceListResult", pipeline_response) @@ -1014,10 +903,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1028,7 +918,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_security_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_security_rules_operations.py new file mode 100644 index 000000000000..03f72d3338f7 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_security_rules_operations.py @@ -0,0 +1,813 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._dns_security_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DnsSecurityRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_security_rules` 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, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRule, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsSecurityRule") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: _models.DnsSecurityRule, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRule + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRule, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsSecurityRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRule or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsSecurityRule] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsSecurityRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsSecurityRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRulePatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = 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, "DnsSecurityRulePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: _models.DnsSecurityRulePatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRulePatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRulePatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsSecurityRulePatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRulePatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsSecurityRule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DnsSecurityRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DnsSecurityRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS security rule for a DNS resolver policy. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, dns_resolver_policy_name: str, dns_security_rule_name: str, **kwargs: Any + ) -> _models.DnsSecurityRule: + """Gets properties of a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :return: DnsSecurityRule or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsSecurityRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsSecurityRule] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, dns_resolver_policy_name: str, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.DnsSecurityRule"]: + """Lists DNS security rules for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsSecurityRule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsSecurityRuleListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsSecurityRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py index fc0d635367c0..850b771397a3 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._forwarding_rules_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +36,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -98,7 +97,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -110,7 +108,7 @@ async def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -127,7 +125,7 @@ async def create_or_update( :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -138,7 +136,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -150,7 +147,7 @@ async def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: Union[_models.ForwardingRule, IO], + parameters: Union[_models.ForwardingRule, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -164,9 +161,9 @@ async def create_or_update( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + ForwardingRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -174,15 +171,11 @@ async def create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,21 +186,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ForwardingRule] = 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, "ForwardingRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, @@ -218,15 +209,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,21 +225,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ForwardingRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } - @overload async def update( self, @@ -280,7 +262,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -292,7 +273,7 @@ async def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -308,7 +289,7 @@ async def update( :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -316,7 +297,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -328,7 +308,7 @@ async def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: Union[_models.ForwardingRulePatch, IO], + parameters: Union[_models.ForwardingRulePatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ForwardingRule: @@ -341,22 +321,18 @@ async def update( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a ForwardingRulePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,21 +343,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ForwardingRule] = 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, "ForwardingRulePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, @@ -391,15 +365,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -408,16 +381,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -442,12 +411,11 @@ async def delete( # pylint: disable=inconsistent-return-statements resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,27 +426,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,11 +453,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -507,12 +468,11 @@ async def get( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,26 +483,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ForwardingRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -551,16 +508,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -576,7 +529,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 ForwardingRule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.ForwardingRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -584,12 +536,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ForwardingRuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,18 +550,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -623,13 +571,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ForwardingRuleListResult", pipeline_response) @@ -639,10 +586,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -653,7 +601,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py index b30409366aa1..ec176dae8829 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._inbound_endpoints_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +40,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,12 +72,12 @@ async def _create_or_update_initial( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpoint, IO], + parameters: Union[_models.InboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.InboundEndpoint]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,21 +88,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.InboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "InboundEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -112,38 +111,33 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -179,14 +173,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -199,7 +185,7 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -216,7 +202,7 @@ async def begin_create_or_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -227,14 +213,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -247,7 +225,7 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpoint, IO], + parameters: Union[_models.InboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -261,9 +239,9 @@ async def begin_create_or_update( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + InboundEndpoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -271,17 +249,6 @@ async def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -290,9 +257,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -313,12 +278,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -328,28 +294,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.InboundEndpoint].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/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return AsyncLROPoller[_models.InboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpointPatch, IO], + parameters: Union[_models.InboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.InboundEndpoint]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,21 +324,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.InboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "InboundEndpointPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -384,35 +346,33 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -444,14 +404,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -464,7 +416,7 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -480,7 +432,7 @@ async def begin_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -488,14 +440,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -508,7 +452,7 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpointPatch, IO], + parameters: Union[_models.InboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.InboundEndpoint]: @@ -521,24 +465,13 @@ async def begin_update( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + InboundEndpointPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -547,9 +480,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -569,12 +500,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -584,27 +516,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.InboundEndpoint].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return AsyncLROPoller[_models.InboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -615,41 +545,43 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -673,14 +605,6 @@ async def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -688,15 +612,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -707,11 +629,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -720,17 +643,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -745,12 +664,11 @@ async def get( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: InboundEndpoint or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.InboundEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,26 +679,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -789,16 +704,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -814,7 +725,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -822,12 +732,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InboundEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -838,18 +746,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -861,13 +767,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("InboundEndpointListResult", pipeline_response) @@ -877,10 +782,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -891,7 +797,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py index edff8c81445e..6488f32c7156 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._outbound_endpoints_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +40,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,12 +72,12 @@ async def _create_or_update_initial( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpoint, IO], + parameters: Union[_models.OutboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OutboundEndpoint]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,21 +88,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OutboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "OutboundEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -112,38 +111,33 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -180,14 +174,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -200,7 +186,7 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -218,7 +204,7 @@ async def begin_create_or_update( Required. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -229,14 +215,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -249,7 +227,7 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpoint, IO], + parameters: Union[_models.OutboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -264,9 +242,9 @@ async def begin_create_or_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + OutboundEndpoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -274,17 +252,6 @@ async def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -293,9 +260,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -316,12 +281,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -331,28 +297,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OutboundEndpoint].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/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return AsyncLROPoller[_models.OutboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpointPatch, IO], + parameters: Union[_models.OutboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OutboundEndpoint]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,21 +327,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OutboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "OutboundEndpointPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -387,35 +349,33 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -448,14 +408,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -468,7 +420,7 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -485,7 +437,7 @@ async def begin_update( Required. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -493,14 +445,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -513,7 +457,7 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpointPatch, IO], + parameters: Union[_models.OutboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.OutboundEndpoint]: @@ -527,24 +471,13 @@ async def begin_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + OutboundEndpointPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -553,9 +486,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -575,12 +506,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -590,27 +522,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OutboundEndpoint].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return AsyncLROPoller[_models.OutboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -621,41 +551,43 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -680,14 +612,6 @@ async def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -695,15 +619,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -714,11 +636,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -727,17 +650,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -753,12 +672,11 @@ async def get( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OutboundEndpoint or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -769,26 +687,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -797,16 +712,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -822,7 +733,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -831,12 +741,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -847,18 +755,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -870,13 +776,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEndpointListResult", pipeline_response) @@ -886,10 +791,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -900,7 +806,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py index 93a43301a532..48d69c9bb97b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._virtual_network_links_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +40,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,12 +72,12 @@ async def _create_or_update_initial( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLink, IO], + parameters: Union[_models.VirtualNetworkLink, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.VirtualNetworkLink]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,21 +88,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualNetworkLink]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "VirtualNetworkLink") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -112,38 +111,33 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -179,14 +173,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -199,7 +185,7 @@ async def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -216,7 +202,7 @@ async def begin_create_or_update( :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -227,14 +213,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -247,7 +225,7 @@ async def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLink, IO], + parameters: Union[_models.VirtualNetworkLink, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -261,9 +239,9 @@ async def begin_create_or_update( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + VirtualNetworkLink type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -271,17 +249,6 @@ async def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -290,9 +257,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -313,12 +278,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -328,28 +294,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualNetworkLink].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/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return AsyncLROPoller[_models.VirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLinkPatch, IO], + parameters: Union[_models.VirtualNetworkLinkPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.VirtualNetworkLink]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,21 +324,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualNetworkLink]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = 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, "VirtualNetworkLinkPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -384,35 +346,33 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -444,14 +404,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -464,7 +416,7 @@ async def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -480,7 +432,7 @@ async def begin_update( :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -488,14 +440,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -508,7 +452,7 @@ async def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLinkPatch, IO], + parameters: Union[_models.VirtualNetworkLinkPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.VirtualNetworkLink]: @@ -521,24 +465,13 @@ async def begin_update( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + VirtualNetworkLinkPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -547,9 +480,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -569,12 +500,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -584,27 +516,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualNetworkLink].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return AsyncLROPoller[_models.VirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -615,41 +545,43 @@ 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["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True 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 if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -674,14 +606,6 @@ async def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -689,15 +613,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -708,11 +630,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -721,17 +644,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -746,12 +665,11 @@ async def get( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualNetworkLink or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -762,26 +680,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -790,16 +705,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -815,7 +726,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -824,12 +734,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkLinkListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -840,18 +748,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -863,13 +769,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkLinkListResult", pipeline_response) @@ -879,10 +784,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -893,7 +799,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py index 9b9affaf7035..8633507d6d88 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py @@ -11,8 +11,24 @@ from ._models_py3 import DnsForwardingRulesetListResult from ._models_py3 import DnsForwardingRulesetPatch from ._models_py3 import DnsResolver +from ._models_py3 import DnsResolverDomainList +from ._models_py3 import DnsResolverDomainListPatch +from ._models_py3 import DnsResolverDomainListResult from ._models_py3 import DnsResolverListResult from ._models_py3 import DnsResolverPatch +from ._models_py3 import DnsResolverPolicy +from ._models_py3 import DnsResolverPolicyListResult +from ._models_py3 import DnsResolverPolicyPatch +from ._models_py3 import DnsResolverPolicyVirtualNetworkLink +from ._models_py3 import DnsResolverPolicyVirtualNetworkLinkListResult +from ._models_py3 import DnsResolverPolicyVirtualNetworkLinkPatch +from ._models_py3 import DnsSecurityRule +from ._models_py3 import DnsSecurityRuleAction +from ._models_py3 import DnsSecurityRuleListResult +from ._models_py3 import DnsSecurityRulePatch +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse from ._models_py3 import ForwardingRule from ._models_py3 import ForwardingRuleListResult from ._models_py3 import ForwardingRulePatch @@ -36,8 +52,11 @@ from ._models_py3 import VirtualNetworkLinkListResult from ._models_py3 import VirtualNetworkLinkPatch +from ._dns_resolver_management_client_enums import ActionType +from ._dns_resolver_management_client_enums import BlockResponseCode from ._dns_resolver_management_client_enums import CreatedByType from ._dns_resolver_management_client_enums import DnsResolverState +from ._dns_resolver_management_client_enums import DnsSecurityRuleState from ._dns_resolver_management_client_enums import ForwardingRuleState from ._dns_resolver_management_client_enums import IpAllocationMethod from ._dns_resolver_management_client_enums import ProvisioningState @@ -51,8 +70,24 @@ "DnsForwardingRulesetListResult", "DnsForwardingRulesetPatch", "DnsResolver", + "DnsResolverDomainList", + "DnsResolverDomainListPatch", + "DnsResolverDomainListResult", "DnsResolverListResult", "DnsResolverPatch", + "DnsResolverPolicy", + "DnsResolverPolicyListResult", + "DnsResolverPolicyPatch", + "DnsResolverPolicyVirtualNetworkLink", + "DnsResolverPolicyVirtualNetworkLinkListResult", + "DnsResolverPolicyVirtualNetworkLinkPatch", + "DnsSecurityRule", + "DnsSecurityRuleAction", + "DnsSecurityRuleListResult", + "DnsSecurityRulePatch", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ForwardingRule", "ForwardingRuleListResult", "ForwardingRulePatch", @@ -75,8 +110,11 @@ "VirtualNetworkLink", "VirtualNetworkLinkListResult", "VirtualNetworkLinkPatch", + "ActionType", + "BlockResponseCode", "CreatedByType", "DnsResolverState", + "DnsSecurityRuleState", "ForwardingRuleState", "IpAllocationMethod", "ProvisioningState", diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py index 5dbf26fcd3ea..69f3a389612b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py @@ -10,6 +10,20 @@ from azure.core import CaseInsensitiveEnumMeta +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of action to take.""" + + ALLOW = "Allow" + ALERT = "Alert" + BLOCK = "Block" + + +class BlockResponseCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The response code for block actions.""" + + SERVFAIL = "SERVFAIL" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -28,6 +42,13 @@ class DnsResolverState(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISCONNECTED = "Disconnected" +class DnsSecurityRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of DNS security rule.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class ForwardingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of forwarding rule.""" diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py index 12e7fa250c83..5642f2bbaf22 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -44,8 +44,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[List["_models.CloudErrorBody"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: The error code. :paramtype code: str @@ -68,51 +68,61 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None + self.system_data = None class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. @@ -123,6 +133,7 @@ class TrackedResource(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -130,11 +141,12 @@ class TrackedResource(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -151,24 +163,25 @@ class DnsForwardingRuleset(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar etag: ETag of the DNS forwarding ruleset. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints that are used to route DNS queries matching the forwarding rules in the ruleset to the target DNS servers. Required. @@ -185,9 +198,9 @@ class DnsForwardingRuleset(TrackedResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "etag": {"readonly": True}, - "system_data": {"readonly": True}, "dns_resolver_outbound_endpoints": {"required": True}, "provisioning_state": {"readonly": True}, "resource_guid": {"readonly": True}, @@ -197,10 +210,10 @@ class DnsForwardingRuleset(TrackedResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "dns_resolver_outbound_endpoints": {"key": "properties.dnsResolverOutboundEndpoints", "type": "[SubResource]"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "resource_guid": {"key": "properties.resourceGuid", "type": "str"}, @@ -212,8 +225,8 @@ def __init__( location: str, dns_resolver_outbound_endpoints: List["_models.SubResource"], tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -226,7 +239,6 @@ def __init__( """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None - self.system_data = None self.dns_resolver_outbound_endpoints = dns_resolver_outbound_endpoints self.provisioning_state = None self.resource_guid = None @@ -252,7 +264,7 @@ class DnsForwardingRulesetListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.DnsForwardingRuleset"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.DnsForwardingRuleset"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the DNS forwarding rulesets. :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -283,8 +295,8 @@ def __init__( *, dns_resolver_outbound_endpoints: Optional[List["_models.SubResource"]] = None, tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints that are used to route DNS queries matching the forwarding rules in the ruleset to the target @@ -303,24 +315,25 @@ class DnsResolver(TrackedResource): # pylint: disable=too-many-instance-attribu Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar etag: ETag of the DNS resolver. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar virtual_network: The reference to the virtual network. This cannot be changed after creation. Required. :vartype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource @@ -340,9 +353,9 @@ class DnsResolver(TrackedResource): # pylint: disable=too-many-instance-attribu "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "etag": {"readonly": True}, - "system_data": {"readonly": True}, "virtual_network": {"required": True}, "dns_resolver_state": {"readonly": True}, "provisioning_state": {"readonly": True}, @@ -353,10 +366,10 @@ class DnsResolver(TrackedResource): # pylint: disable=too-many-instance-attribu "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "virtual_network": {"key": "properties.virtualNetwork", "type": "SubResource"}, "dns_resolver_state": {"key": "properties.dnsResolverState", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, @@ -364,8 +377,13 @@ class DnsResolver(TrackedResource): # pylint: disable=too-many-instance-attribu } def __init__( - self, *, location: str, virtual_network: "_models.SubResource", tags: Optional[Dict[str, str]] = None, **kwargs - ): + self, + *, + location: str, + virtual_network: "_models.SubResource", + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -377,13 +395,147 @@ def __init__( """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None - self.system_data = None self.virtual_network = virtual_network self.dns_resolver_state = None self.provisioning_state = None self.resource_guid = None +class DnsResolverDomainList(TrackedResource): + """Describes a DNS resolver domain list. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: ETag of the DNS resolver domain list. + :vartype etag: str + :ivar domains: The domains in the domain list. Required. + :vartype domains: list[str] + :ivar provisioning_state: The current provisioning state of the DNS resolver domain list. This + is a read-only property and any attempt to set this value will be ignored. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState + :ivar resource_guid: The resourceGuid property of the DNS resolver domain list resource. + :vartype resource_guid: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "domains": {"required": True}, + "provisioning_state": {"readonly": True}, + "resource_guid": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "domains": {"key": "properties.domains", "type": "[str]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "resource_guid": {"key": "properties.resourceGuid", "type": "str"}, + } + + def __init__( + self, *, location: str, domains: List[str], tags: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword domains: The domains in the domain list. Required. + :paramtype domains: list[str] + """ + super().__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.domains = domains + self.provisioning_state = None + self.resource_guid = None + + +class DnsResolverDomainListPatch(_serialization.Model): + """Describes a DNS resolver domain list for PATCH operation. + + :ivar tags: Tags for DNS resolver domain list. + :vartype tags: dict[str, str] + :ivar domains: The domains in the domain list. + :vartype domains: list[str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "domains": {"key": "properties.domains", "type": "[str]"}, + } + + def __init__( + self, *, tags: Optional[Dict[str, str]] = None, domains: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword tags: Tags for DNS resolver domain list. + :paramtype tags: dict[str, str] + :keyword domains: The domains in the domain list. + :paramtype domains: list[str] + """ + super().__init__(**kwargs) + self.tags = tags + self.domains = domains + + +class DnsResolverDomainListResult(_serialization.Model): + """The response to an enumeration operation on DNS resolver domain lists. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS resolver domain lists. + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :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": "[DnsResolverDomainList]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DnsResolverDomainList"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Enumeration of the DNS resolver domain lists. + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + class DnsResolverListResult(_serialization.Model): """The response to an enumeration operation on DNS resolvers. @@ -404,7 +556,7 @@ class DnsResolverListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.DnsResolver"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.DnsResolver"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the DNS resolvers. :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -425,7 +577,7 @@ class DnsResolverPatch(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Tags for DNS Resolver. :paramtype tags: dict[str, str] @@ -434,36 +586,589 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): self.tags = tags -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. +class DnsResolverPolicy(TrackedResource): + """Describes a DNS resolver policy. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: ETag of the DNS resolver policy. + :vartype etag: str + :ivar provisioning_state: The current provisioning state of the DNS resolver policy. This is a + read-only property and any attempt to set this value will be ignored. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState + :ivar resource_guid: The resourceGuid property of the DNS resolver policy resource. + :vartype resource_guid: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "resource_guid": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "resource_guid": {"key": "properties.resourceGuid", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.provisioning_state = None + self.resource_guid = None + + +class DnsResolverPolicyListResult(_serialization.Model): + """The response to an enumeration operation on DNS resolver policies. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS resolver policies. + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :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": "[DnsResolverPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DnsResolverPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Enumeration of the DNS resolver policies. + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class DnsResolverPolicyPatch(_serialization.Model): + """Describes a DNS resolver policy for PATCH operation. + + :ivar tags: Tags for DNS resolver policy. + :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: Tags for DNS resolver policy. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class DnsResolverPolicyVirtualNetworkLink(TrackedResource): + """Describes a DNS resolver policy virtual network link. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: ETag of the DNS resolver policy virtual network link. + :vartype etag: str + :ivar virtual_network: The reference to the virtual network. This cannot be changed after + creation. Required. + :vartype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource + :ivar provisioning_state: The current provisioning state of the DNS resolver policy virtual + network link. This is a read-only property and any attempt to set this value will be ignored. + Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "virtual_network": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "virtual_network": {"key": "properties.virtualNetwork", "type": "SubResource"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + virtual_network: "_models.SubResource", + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword virtual_network: The reference to the virtual network. This cannot be changed after + creation. Required. + :paramtype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource + """ + super().__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.virtual_network = virtual_network + self.provisioning_state = None + + +class DnsResolverPolicyVirtualNetworkLinkListResult(_serialization.Model): # pylint: disable=name-too-long + """The response to an enumeration operation on DNS resolver policy virtual network links. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS resolver policy virtual network links. + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :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": "[DnsResolverPolicyVirtualNetworkLink]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.DnsResolverPolicyVirtualNetworkLink"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Enumeration of the DNS resolver policy virtual network links. + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class DnsResolverPolicyVirtualNetworkLinkPatch(_serialization.Model): + """Describes a DNS resolver policy virtual network link for PATCH operation. + + :ivar tags: Tags for the DNS resolver policy virtual network link. + :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: Tags for the DNS resolver policy virtual network link. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class DnsSecurityRule(TrackedResource): # pylint: disable=too-many-instance-attributes + """Describes a DNS security rule. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: ETag of the DNS security rule. + :vartype etag: str + :ivar priority: The priority of the DNS security rule. Required. + :vartype priority: int + :ivar action: The action to take on DNS requests that match the DNS security rule. Required. + :vartype action: ~azure.mgmt.dnsresolver.models.DnsSecurityRuleAction + :ivar dns_resolver_domain_lists: DNS resolver policy domains lists that the DNS security rule + applies to. Required. + :vartype dns_resolver_domain_lists: list[~azure.mgmt.dnsresolver.models.SubResource] + :ivar dns_security_rule_state: The state of DNS security rule. Known values are: "Enabled" and + "Disabled". + :vartype dns_security_rule_state: str or ~azure.mgmt.dnsresolver.models.DnsSecurityRuleState + :ivar provisioning_state: The current provisioning state of the DNS security rule. This is a + read-only property and any attempt to set this value will be ignored. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "priority": {"required": True}, + "action": {"required": True}, + "dns_resolver_domain_lists": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "priority": {"key": "properties.priority", "type": "int"}, + "action": {"key": "properties.action", "type": "DnsSecurityRuleAction"}, + "dns_resolver_domain_lists": {"key": "properties.dnsResolverDomainLists", "type": "[SubResource]"}, + "dns_security_rule_state": {"key": "properties.dnsSecurityRuleState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, **kwargs): + def __init__( + self, + *, + location: str, + priority: int, + action: "_models.DnsSecurityRuleAction", + dns_resolver_domain_lists: List["_models.SubResource"], + tags: Optional[Dict[str, str]] = None, + dns_security_rule_state: Optional[Union[str, "_models.DnsSecurityRuleState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword priority: The priority of the DNS security rule. Required. + :paramtype priority: int + :keyword action: The action to take on DNS requests that match the DNS security rule. Required. + :paramtype action: ~azure.mgmt.dnsresolver.models.DnsSecurityRuleAction + :keyword dns_resolver_domain_lists: DNS resolver policy domains lists that the DNS security + rule applies to. Required. + :paramtype dns_resolver_domain_lists: list[~azure.mgmt.dnsresolver.models.SubResource] + :keyword dns_security_rule_state: The state of DNS security rule. Known values are: "Enabled" + and "Disabled". + :paramtype dns_security_rule_state: str or ~azure.mgmt.dnsresolver.models.DnsSecurityRuleState + """ + super().__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.priority = priority + self.action = action + self.dns_resolver_domain_lists = dns_resolver_domain_lists + self.dns_security_rule_state = dns_security_rule_state + self.provisioning_state = None + + +class DnsSecurityRuleAction(_serialization.Model): + """The action to take on DNS requests that match the DNS security rule. + + :ivar action_type: The type of action to take. Known values are: "Allow", "Alert", and "Block". + :vartype action_type: str or ~azure.mgmt.dnsresolver.models.ActionType + :ivar block_response_code: The response code for block actions. "SERVFAIL" + :vartype block_response_code: str or ~azure.mgmt.dnsresolver.models.BlockResponseCode + """ + + _attribute_map = { + "action_type": {"key": "actionType", "type": "str"}, + "block_response_code": {"key": "blockResponseCode", "type": "str"}, + } + + def __init__( + self, + *, + action_type: Optional[Union[str, "_models.ActionType"]] = None, + block_response_code: Optional[Union[str, "_models.BlockResponseCode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword action_type: The type of action to take. Known values are: "Allow", "Alert", and + "Block". + :paramtype action_type: str or ~azure.mgmt.dnsresolver.models.ActionType + :keyword block_response_code: The response code for block actions. "SERVFAIL" + :paramtype block_response_code: str or ~azure.mgmt.dnsresolver.models.BlockResponseCode + """ + super().__init__(**kwargs) + self.action_type = action_type + self.block_response_code = block_response_code + + +class DnsSecurityRuleListResult(_serialization.Model): + """The response to an enumeration operation on DNS security rules within a DNS resolver policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS security rules. + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :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": "[DnsSecurityRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.DnsSecurityRule"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Enumeration of the DNS security rules. + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class DnsSecurityRulePatch(_serialization.Model): + """Describes a DNS security rule for PATCH operation. + + :ivar tags: Tags for DNS security rule. + :vartype tags: dict[str, str] + :ivar action: The action to take on DNS requests that match the DNS security rule. + :vartype action: ~azure.mgmt.dnsresolver.models.DnsSecurityRuleAction + :ivar dns_resolver_domain_lists: DNS resolver policy domains lists that the DNS security rule + applies to. + :vartype dns_resolver_domain_lists: list[~azure.mgmt.dnsresolver.models.SubResource] + :ivar dns_security_rule_state: The state of DNS security rule. Known values are: "Enabled" and + "Disabled". + :vartype dns_security_rule_state: str or ~azure.mgmt.dnsresolver.models.DnsSecurityRuleState + :ivar priority: The priority of the DNS security rule. + :vartype priority: int + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "action": {"key": "properties.action", "type": "DnsSecurityRuleAction"}, + "dns_resolver_domain_lists": {"key": "properties.dnsResolverDomainLists", "type": "[SubResource]"}, + "dns_security_rule_state": {"key": "properties.dnsSecurityRuleState", "type": "str"}, + "priority": {"key": "properties.priority", "type": "int"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + action: Optional["_models.DnsSecurityRuleAction"] = None, + dns_resolver_domain_lists: Optional[List["_models.SubResource"]] = None, + dns_security_rule_state: Optional[Union[str, "_models.DnsSecurityRuleState"]] = None, + priority: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Tags for DNS security rule. + :paramtype tags: dict[str, str] + :keyword action: The action to take on DNS requests that match the DNS security rule. + :paramtype action: ~azure.mgmt.dnsresolver.models.DnsSecurityRuleAction + :keyword dns_resolver_domain_lists: DNS resolver policy domains lists that the DNS security + rule applies to. + :paramtype dns_resolver_domain_lists: list[~azure.mgmt.dnsresolver.models.SubResource] + :keyword dns_security_rule_state: The state of DNS security rule. Known values are: "Enabled" + and "Disabled". + :paramtype dns_security_rule_state: str or ~azure.mgmt.dnsresolver.models.DnsSecurityRuleState + :keyword priority: The priority of the DNS security rule. + :paramtype priority: int + """ + super().__init__(**kwargs) + self.tags = tags + self.action = action + self.dns_resolver_domain_lists = dns_resolver_domain_lists + self.dns_security_rule_state = dns_security_rule_state + self.priority = priority + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.dnsresolver.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.dnsresolver.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.dnsresolver.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.dnsresolver.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + """ class ForwardingRule(ProxyResource): @@ -471,20 +1176,21 @@ class ForwardingRule(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar etag: ETag of the forwarding rule. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar domain_name: The domain name for the forwarding rule. Required. :vartype domain_name: str :ivar target_dns_servers: DNS servers to forward the DNS query to. Required. @@ -504,8 +1210,8 @@ class ForwardingRule(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "etag": {"readonly": True}, "system_data": {"readonly": True}, + "etag": {"readonly": True}, "domain_name": {"required": True}, "target_dns_servers": {"required": True}, "provisioning_state": {"readonly": True}, @@ -515,8 +1221,8 @@ class ForwardingRule(ProxyResource): "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"}, + "etag": {"key": "etag", "type": "str"}, "domain_name": {"key": "properties.domainName", "type": "str"}, "target_dns_servers": {"key": "properties.targetDnsServers", "type": "[TargetDnsServer]"}, "metadata": {"key": "properties.metadata", "type": "{str}"}, @@ -531,8 +1237,8 @@ def __init__( target_dns_servers: List["_models.TargetDnsServer"], metadata: Optional[Dict[str, str]] = None, forwarding_rule_state: Optional[Union[str, "_models.ForwardingRuleState"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword domain_name: The domain name for the forwarding rule. Required. :paramtype domain_name: str @@ -546,7 +1252,6 @@ def __init__( """ super().__init__(**kwargs) self.etag = None - self.system_data = None self.domain_name = domain_name self.target_dns_servers = target_dns_servers self.metadata = metadata @@ -574,7 +1279,7 @@ class ForwardingRuleListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ForwardingRule"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ForwardingRule"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the forwarding rules. :paramtype value: list[~azure.mgmt.dnsresolver.models.ForwardingRule] @@ -608,8 +1313,8 @@ def __init__( target_dns_servers: Optional[List["_models.TargetDnsServer"]] = None, metadata: Optional[Dict[str, str]] = None, forwarding_rule_state: Optional[Union[str, "_models.ForwardingRuleState"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword target_dns_servers: DNS servers to forward the DNS query to. :paramtype target_dns_servers: list[~azure.mgmt.dnsresolver.models.TargetDnsServer] @@ -630,24 +1335,25 @@ class InboundEndpoint(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar etag: ETag of the inbound endpoint. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar ip_configurations: IP configurations for the inbound endpoint. Required. :vartype ip_configurations: list[~azure.mgmt.dnsresolver.models.IpConfiguration] :ivar provisioning_state: The current provisioning state of the inbound endpoint. This is a @@ -662,9 +1368,9 @@ class InboundEndpoint(TrackedResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "etag": {"readonly": True}, - "system_data": {"readonly": True}, "ip_configurations": {"required": True}, "provisioning_state": {"readonly": True}, "resource_guid": {"readonly": True}, @@ -674,10 +1380,10 @@ class InboundEndpoint(TrackedResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "ip_configurations": {"key": "properties.ipConfigurations", "type": "[IpConfiguration]"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "resource_guid": {"key": "properties.resourceGuid", "type": "str"}, @@ -689,8 +1395,8 @@ def __init__( location: str, ip_configurations: List["_models.IpConfiguration"], tags: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -701,7 +1407,6 @@ def __init__( """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None - self.system_data = None self.ip_configurations = ip_configurations self.provisioning_state = None self.resource_guid = None @@ -727,7 +1432,7 @@ class InboundEndpointListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.InboundEndpoint"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.InboundEndpoint"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the inbound endpoints for a DNS resolver. :paramtype value: list[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -748,7 +1453,7 @@ class InboundEndpointPatch(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Tags for inbound endpoint. :paramtype tags: dict[str, str] @@ -760,7 +1465,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): class IpConfiguration(_serialization.Model): """IP configuration. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar subnet: The reference to the subnet bound to the IP configuration. Required. :vartype subnet: ~azure.mgmt.dnsresolver.models.SubResource @@ -787,8 +1492,8 @@ def __init__( subnet: "_models.SubResource", private_ip_address: Optional[str] = None, private_ip_allocation_method: Union[str, "_models.IpAllocationMethod"] = "Dynamic", - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword subnet: The reference to the subnet bound to the IP configuration. Required. :paramtype subnet: ~azure.mgmt.dnsresolver.models.SubResource @@ -810,24 +1515,25 @@ class OutboundEndpoint(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar etag: ETag of the outbound endpoint. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar subnet: The reference to the subnet used for the outbound endpoint. Required. :vartype subnet: ~azure.mgmt.dnsresolver.models.SubResource :ivar provisioning_state: The current provisioning state of the outbound endpoint. This is a @@ -842,9 +1548,9 @@ class OutboundEndpoint(TrackedResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "etag": {"readonly": True}, - "system_data": {"readonly": True}, "subnet": {"required": True}, "provisioning_state": {"readonly": True}, "resource_guid": {"readonly": True}, @@ -854,18 +1560,18 @@ class OutboundEndpoint(TrackedResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, "subnet": {"key": "properties.subnet", "type": "SubResource"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "resource_guid": {"key": "properties.resourceGuid", "type": "str"}, } def __init__( - self, *, location: str, subnet: "_models.SubResource", tags: Optional[Dict[str, str]] = None, **kwargs - ): + self, *, location: str, subnet: "_models.SubResource", tags: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -876,7 +1582,6 @@ def __init__( """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None - self.system_data = None self.subnet = subnet self.provisioning_state = None self.resource_guid = None @@ -902,7 +1607,7 @@ class OutboundEndpointListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.OutboundEndpoint"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.OutboundEndpoint"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the outbound endpoints for a DNS resolver. :paramtype value: list[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -923,7 +1628,7 @@ class OutboundEndpointPatch(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Tags for outbound endpoint. :paramtype tags: dict[str, str] @@ -935,7 +1640,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): class SubResource(_serialization.Model): """Reference to another ARM resource. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. Required. :vartype id: str @@ -949,7 +1654,7 @@ class SubResource(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ :keyword id: Resource ID. Required. :paramtype id: str @@ -978,7 +1683,7 @@ class SubResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.SubResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.SubResource"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the sub-resources. :paramtype value: list[~azure.mgmt.dnsresolver.models.SubResource] @@ -1025,8 +1730,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1055,7 +1760,7 @@ def __init__( class TargetDnsServer(_serialization.Model): """Describes a server to forward the DNS queries to. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar ip_address: DNS server IP address. Required. :vartype ip_address: str @@ -1072,7 +1777,7 @@ class TargetDnsServer(_serialization.Model): "port": {"key": "port", "type": "int"}, } - def __init__(self, *, ip_address: str, port: int = 53, **kwargs): + def __init__(self, *, ip_address: str, port: int = 53, **kwargs: Any) -> None: """ :keyword ip_address: DNS server IP address. Required. :paramtype ip_address: str @@ -1103,8 +1808,8 @@ def __init__( *, id: Optional[str] = None, # pylint: disable=redefined-builtin virtual_network_link: Optional["_models.SubResource"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: DNS Forwarding Ruleset Resource ID. :paramtype id: str @@ -1116,7 +1821,7 @@ def __init__( self.virtual_network_link = virtual_network_link -class VirtualNetworkDnsForwardingRulesetListResult(_serialization.Model): +class VirtualNetworkDnsForwardingRulesetListResult(_serialization.Model): # pylint: disable=name-too-long """The response to an enumeration operation on Virtual Network DNS Forwarding Ruleset. Variables are only populated by the server, and will be ignored when sending a request. @@ -1136,7 +1841,9 @@ class VirtualNetworkDnsForwardingRulesetListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.VirtualNetworkDnsForwardingRuleset"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.VirtualNetworkDnsForwardingRuleset"]] = None, **kwargs: Any + ) -> None: """ :keyword value: Enumeration of the Virtual Network DNS Forwarding Ruleset. :paramtype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkDnsForwardingRuleset] @@ -1151,20 +1858,21 @@ class VirtualNetworkLink(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar etag: ETag of the virtual network link. :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData :ivar virtual_network: The reference to the virtual network. This cannot be changed after creation. Required. :vartype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource @@ -1180,8 +1888,8 @@ class VirtualNetworkLink(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "etag": {"readonly": True}, "system_data": {"readonly": True}, + "etag": {"readonly": True}, "virtual_network": {"required": True}, "provisioning_state": {"readonly": True}, } @@ -1190,14 +1898,16 @@ class VirtualNetworkLink(ProxyResource): "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"}, + "etag": {"key": "etag", "type": "str"}, "virtual_network": {"key": "properties.virtualNetwork", "type": "SubResource"}, "metadata": {"key": "properties.metadata", "type": "{str}"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, virtual_network: "_models.SubResource", metadata: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, virtual_network: "_models.SubResource", metadata: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword virtual_network: The reference to the virtual network. This cannot be changed after creation. Required. @@ -1207,7 +1917,6 @@ def __init__(self, *, virtual_network: "_models.SubResource", metadata: Optional """ super().__init__(**kwargs) self.etag = None - self.system_data = None self.virtual_network = virtual_network self.metadata = metadata self.provisioning_state = None @@ -1233,7 +1942,7 @@ class VirtualNetworkLinkListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.VirtualNetworkLink"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.VirtualNetworkLink"]] = None, **kwargs: Any) -> None: """ :keyword value: Enumeration of the virtual network links. :paramtype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -1254,7 +1963,7 @@ class VirtualNetworkLinkPatch(_serialization.Model): "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword metadata: Metadata attached to the virtual network link. :paramtype metadata: dict[str, str] diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py index 231d09975ac1..b81ec42ea3c5 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py @@ -12,6 +12,10 @@ from ._dns_forwarding_rulesets_operations import DnsForwardingRulesetsOperations from ._forwarding_rules_operations import ForwardingRulesOperations from ._virtual_network_links_operations import VirtualNetworkLinksOperations +from ._dns_resolver_policies_operations import DnsResolverPoliciesOperations +from ._dns_security_rules_operations import DnsSecurityRulesOperations +from ._dns_resolver_policy_virtual_network_links_operations import DnsResolverPolicyVirtualNetworkLinksOperations +from ._dns_resolver_domain_lists_operations import DnsResolverDomainListsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -24,6 +28,10 @@ "DnsForwardingRulesetsOperations", "ForwardingRulesOperations", "VirtualNetworkLinksOperations", + "DnsResolverPoliciesOperations", + "DnsSecurityRulesOperations", + "DnsResolverPolicyVirtualNetworkLinksOperations", + "DnsResolverDomainListsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py index eac8bbb4452c..cc0b778bdc49 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +56,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -65,14 +66,14 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +101,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -110,14 +111,14 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,14 +153,14 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,14 +188,14 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +212,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,13 +221,13 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +244,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,10 +252,10 @@ def build_list_request(subscription_id: str, *, top: Optional[int] = None, **kwa "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets" ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -278,7 +279,7 @@ def build_list_by_virtual_network_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -287,14 +288,14 @@ def build_list_by_virtual_network_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,12 +331,12 @@ def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRuleset, IO], + parameters: Union[_models.DnsForwardingRuleset, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsForwardingRuleset]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,21 +347,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsForwardingRuleset]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "DnsForwardingRuleset") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, @@ -370,38 +369,33 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -434,14 +428,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -453,7 +439,7 @@ def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -468,7 +454,7 @@ def begin_create_or_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -479,14 +465,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -498,7 +476,7 @@ def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRuleset, IO], + parameters: Union[_models.DnsForwardingRuleset, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -510,9 +488,9 @@ def begin_create_or_update( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsForwardingRuleset type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -520,17 +498,6 @@ def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -539,9 +506,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -561,12 +526,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -576,27 +542,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DnsForwardingRuleset].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/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return LROPoller[_models.DnsForwardingRuleset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRulesetPatch, IO], + parameters: Union[_models.DnsForwardingRulesetPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsForwardingRuleset]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -607,21 +571,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsForwardingRuleset]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "DnsForwardingRulesetPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, @@ -630,35 +592,33 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -687,14 +647,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -706,7 +658,7 @@ def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -720,7 +672,7 @@ def begin_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -728,14 +680,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -747,7 +691,7 @@ def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: Union[_models.DnsForwardingRulesetPatch, IO], + parameters: Union[_models.DnsForwardingRulesetPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.DnsForwardingRuleset]: @@ -758,24 +702,13 @@ def begin_update( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + DnsForwardingRulesetPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -784,9 +717,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -805,12 +736,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -820,22 +752,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DnsForwardingRuleset].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return LROPoller[_models.DnsForwardingRuleset]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -846,40 +776,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -897,14 +829,6 @@ def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -912,15 +836,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, if_match=if_match, @@ -930,11 +852,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -943,17 +866,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -966,12 +885,11 @@ def get( :type resource_group_name: str :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. Required. :type dns_forwarding_ruleset_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,25 +900,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRuleset] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1009,16 +924,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response) + deserialized = self._deserialize("DnsForwardingRuleset", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -1032,7 +943,6 @@ def list_by_resource_group( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -1041,12 +951,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1057,17 +965,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1079,13 +985,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) @@ -1095,10 +1000,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1110,10 +1016,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.DnsForwardingRuleset"]: """Lists DNS forwarding rulesets in all resource groups of a subscription. @@ -1121,7 +1023,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsForwardingRuleset or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] @@ -1130,12 +1031,10 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1146,16 +1045,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1167,13 +1064,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) @@ -1183,10 +1079,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1198,8 +1095,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets"} - @distributed_trace def list_by_virtual_network( self, resource_group_name: str, virtual_network_name: str, top: Optional[int] = None, **kwargs: Any @@ -1214,7 +1109,6 @@ def list_by_virtual_network( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 VirtualNetworkDnsForwardingRuleset or the result of cls(response) :rtype: @@ -1224,12 +1118,10 @@ def list_by_virtual_network( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkDnsForwardingRulesetListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1240,18 +1132,16 @@ def list_by_virtual_network( def prepare_request(next_link=None): if not next_link: - request = build_list_by_virtual_network_request( + _request = build_list_by_virtual_network_request( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_virtual_network.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1263,13 +1153,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkDnsForwardingRulesetListResult", pipeline_response) @@ -1279,10 +1168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1293,7 +1183,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_domain_lists_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_domain_lists_operations.py new file mode 100644 index 000000000000..ad9738063a61 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_domain_lists_operations.py @@ -0,0 +1,1105 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + dns_resolver_domain_list_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/dnsResolverDomainLists/{dnsResolverDomainListName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverDomainListName": _SERIALIZER.url( + "dns_resolver_domain_list_name", + dns_resolver_domain_list_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_update_request( + resource_group_name: str, + dns_resolver_domain_list_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/dnsResolverDomainLists/{dnsResolverDomainListName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverDomainListName": _SERIALIZER.url( + "dns_resolver_domain_list_name", + dns_resolver_domain_list_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_delete_request( + resource_group_name: str, + dns_resolver_domain_list_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/dnsResolverDomainLists/{dnsResolverDomainListName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverDomainListName": _SERIALIZER.url( + "dns_resolver_domain_list_name", + dns_resolver_domain_list_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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, dns_resolver_domain_list_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/dnsResolverDomainLists/{dnsResolverDomainListName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverDomainListName": _SERIALIZER.url( + "dns_resolver_domain_list_name", + dns_resolver_domain_list_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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/dnsResolverDomainLists", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # 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/dnsResolverDomainLists" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnsResolverDomainListsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_resolver_domain_lists` 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, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainList, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverDomainList") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: _models.DnsResolverDomainList, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainList, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Creates or updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverDomainList type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverDomainList] = 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, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverDomainList].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverDomainList]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainListPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverDomainListPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: _models.DnsResolverDomainListPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainListPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + parameters: Union[_models.DnsResolverDomainListPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverDomainList]: + """Updates a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverDomainListPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverDomainListPatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverDomainList] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverDomainList].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverDomainList]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_domain_list_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS resolver domain list. WARNING: 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 dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, dns_resolver_domain_list_name: str, **kwargs: Any + ) -> _models.DnsResolverDomainList: + """Gets properties of a DNS resolver domain list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_domain_list_name: The name of the DNS resolver domain list. Required. + :type dns_resolver_domain_list_name: str + :return: DnsResolverDomainList or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverDomainList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainList] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_domain_list_name=dns_resolver_domain_list_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverDomainList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DnsResolverDomainList"]: + """Lists DNS resolver domain lists 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 results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.DnsResolverDomainList"]: + """Lists DNS resolver domain lists in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverDomainList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverDomainList] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverDomainListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverDomainListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policies_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policies_operations.py new file mode 100644 index 000000000000..7fa0f16e8049 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policies_operations.py @@ -0,0 +1,1210 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_update_request( + resource_group_name: str, + dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_delete_request( + resource_group_name: str, + dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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, dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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/dnsResolverPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # 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/dnsResolverPolicies") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_virtual_network_request( + resource_group_name: str, virtual_network_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/virtualNetworks/{virtualNetworkName}/listDnsResolverPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "virtualNetworkName": _SERIALIZER.url( + "virtual_network_name", virtual_network_name, "str", min_length=1, pattern=r"^.+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnsResolverPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_resolver_policies` 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, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicy, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverPolicy") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: _models.DnsResolverPolicy, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicy, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Creates or updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicy] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicyPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverPolicyPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: _models.DnsResolverPolicyPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + parameters: Union[_models.DnsResolverPolicyPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicy]: + """Updates a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverPolicyPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyPatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either DnsResolverPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, dns_resolver_policy_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, dns_resolver_policy_name: str, if_match: Optional[str] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS resolver policy. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, dns_resolver_policy_name: str, **kwargs: Any) -> _models.DnsResolverPolicy: + """Gets properties of a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :return: DnsResolverPolicy or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicy] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverPolicy", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DnsResolverPolicy"]: + """Lists DNS resolver policies 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 results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.DnsResolverPolicy"]: + """Lists DNS resolver policies in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_virtual_network( + self, resource_group_name: str, virtual_network_name: str, **kwargs: Any + ) -> Iterable["_models.SubResource"]: + """Lists DNS resolver policy resource IDs linked to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. Required. + :type virtual_network_name: str + :return: An iterator like instance of either SubResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.SubResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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_virtual_network_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SubResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policy_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policy_virtual_network_links_operations.py new file mode 100644 index 000000000000..b7682bd4799a --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolver_policy_virtual_network_links_operations.py @@ -0,0 +1,1106 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_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/dnsResolverPolicies/{dnsResolverPolicyName}/virtualNetworkLinks/{dnsResolverPolicyVirtualNetworkLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsResolverPolicyVirtualNetworkLinkName": _SERIALIZER.url( + "dns_resolver_policy_virtual_network_link_name", + dns_resolver_policy_virtual_network_link_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_update_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_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/dnsResolverPolicies/{dnsResolverPolicyName}/virtualNetworkLinks/{dnsResolverPolicyVirtualNetworkLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsResolverPolicyVirtualNetworkLinkName": _SERIALIZER.url( + "dns_resolver_policy_virtual_network_link_name", + dns_resolver_policy_virtual_network_link_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_delete_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_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/dnsResolverPolicies/{dnsResolverPolicyName}/virtualNetworkLinks/{dnsResolverPolicyVirtualNetworkLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsResolverPolicyVirtualNetworkLinkName": _SERIALIZER.url( + "dns_resolver_policy_virtual_network_link_name", + dns_resolver_policy_virtual_network_link_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_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/dnsResolverPolicies/{dnsResolverPolicyName}/virtualNetworkLinks/{dnsResolverPolicyVirtualNetworkLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsResolverPolicyVirtualNetworkLinkName": _SERIALIZER.url( + "dns_resolver_policy_virtual_network_link_name", + dns_resolver_policy_virtual_network_link_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}/virtualNetworkLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnsResolverPolicyVirtualNetworkLinksOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_resolver_policy_virtual_network_links` 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, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLink, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverPolicyVirtualNetworkLink") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: _models.DnsResolverPolicyVirtualNetworkLink, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLink, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Creates or updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsResolverPolicyVirtualNetworkLink type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink or + IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverPolicyVirtualNetworkLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLinkPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverPolicyVirtualNetworkLinkPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: _models.DnsResolverPolicyVirtualNetworkLinkPatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLinkPatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + parameters: Union[_models.DnsResolverPolicyVirtualNetworkLinkPatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]: + """Updates a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsResolverPolicyVirtualNetworkLinkPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLinkPatch or + IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either DnsResolverPolicyVirtualNetworkLink or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsResolverPolicyVirtualNetworkLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsResolverPolicyVirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS resolver policy virtual network link. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_resolver_policy_virtual_network_link_name: str, + **kwargs: Any + ) -> _models.DnsResolverPolicyVirtualNetworkLink: + """Gets properties of a DNS resolver policy virtual network link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_resolver_policy_virtual_network_link_name: The name of the DNS resolver policy + virtual network link for the DNS resolver policy. Required. + :type dns_resolver_policy_virtual_network_link_name: str + :return: DnsResolverPolicyVirtualNetworkLink or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLink] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_resolver_policy_virtual_network_link_name=dns_resolver_policy_virtual_network_link_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLink", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, dns_resolver_policy_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DnsResolverPolicyVirtualNetworkLink"]: + """Lists DNS resolver policy virtual network links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsResolverPolicyVirtualNetworkLink or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverPolicyVirtualNetworkLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsResolverPolicyVirtualNetworkLinkListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverPolicyVirtualNetworkLinkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py index 5590d57f0f8f..b0f325100703 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +56,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -65,14 +66,14 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +101,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -110,14 +111,14 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,14 +153,14 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,14 +188,14 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +212,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,13 +221,13 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,16 +244,16 @@ 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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/dnsResolvers") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,7 +277,7 @@ def build_list_by_virtual_network_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -285,14 +286,14 @@ def build_list_by_virtual_network_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -328,12 +329,12 @@ def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolver, IO], + parameters: Union[_models.DnsResolver, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsResolver]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,21 +345,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsResolver]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolver") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, @@ -368,38 +367,33 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsResolver", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -432,14 +426,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -451,7 +437,7 @@ def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -466,7 +452,7 @@ def begin_create_or_update( :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -477,14 +463,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -496,7 +474,7 @@ def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolver, IO], + parameters: Union[_models.DnsResolver, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -508,9 +486,9 @@ def begin_create_or_update( :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a DnsResolver + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -518,17 +496,6 @@ def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -537,9 +504,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -559,12 +524,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -574,27 +540,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DnsResolver].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/dnsResolvers/{dnsResolverName}" - } + return LROPoller[_models.DnsResolver]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolverPatch, IO], + parameters: Union[_models.DnsResolverPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.DnsResolver]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,21 +569,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DnsResolver]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "DnsResolverPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, @@ -628,35 +590,33 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -685,14 +645,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -704,7 +656,7 @@ def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -718,7 +670,7 @@ def begin_update( :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -726,14 +678,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -745,7 +689,7 @@ def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: Union[_models.DnsResolverPatch, IO], + parameters: Union[_models.DnsResolverPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.DnsResolver]: @@ -756,24 +700,13 @@ def begin_update( :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a DnsResolverPatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 DnsResolver or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] @@ -782,9 +715,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -803,12 +734,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -818,22 +750,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DnsResolver].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return LROPoller[_models.DnsResolver]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -844,40 +774,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -894,14 +826,6 @@ def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -909,15 +833,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, if_match=if_match, @@ -927,11 +849,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -940,17 +863,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: Any) -> _models.DnsResolver: @@ -961,12 +880,11 @@ def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: Any) - :type resource_group_name: str :param dns_resolver_name: The name of the DNS resolver. Required. :type dns_resolver_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResolver or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.DnsResolver :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,25 +895,22 @@ def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolver] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,16 +919,12 @@ def get(self, resource_group_name: str, dns_resolver_name: str, **kwargs: Any) - map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DnsResolver", pipeline_response) + deserialized = self._deserialize("DnsResolver", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -1027,7 +938,6 @@ def list_by_resource_group( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsResolver or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolver] :raises ~azure.core.exceptions.HttpResponseError: @@ -1035,12 +945,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolverListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1051,17 +959,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1073,13 +979,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DnsResolverListResult", pipeline_response) @@ -1089,10 +994,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1104,10 +1010,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers" - } - @distributed_trace def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.DnsResolver"]: """Lists DNS resolvers in all resource groups of a subscription. @@ -1115,7 +1017,6 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 DnsResolver or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolver] :raises ~azure.core.exceptions.HttpResponseError: @@ -1123,12 +1024,10 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DnsResolverListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1139,16 +1038,14 @@ def list(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.Dn def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1160,13 +1057,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DnsResolverListResult", pipeline_response) @@ -1176,10 +1072,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1191,8 +1088,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers"} - @distributed_trace def list_by_virtual_network( self, resource_group_name: str, virtual_network_name: str, top: Optional[int] = None, **kwargs: Any @@ -1207,7 +1102,6 @@ def list_by_virtual_network( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 SubResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.SubResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1215,12 +1109,10 @@ def list_by_virtual_network( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1231,18 +1123,16 @@ def list_by_virtual_network( def prepare_request(next_link=None): if not next_link: - request = build_list_by_virtual_network_request( + _request = build_list_by_virtual_network_request( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_virtual_network.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1254,13 +1144,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SubResourceListResult", pipeline_response) @@ -1270,10 +1159,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1284,7 +1174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_security_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_security_rules_operations.py new file mode 100644 index 000000000000..c58772f423c0 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_security_rules_operations.py @@ -0,0 +1,1085 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_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/dnsResolverPolicies/{dnsResolverPolicyName}/dnsSecurityRules/{dnsSecurityRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsSecurityRuleName": _SERIALIZER.url( + "dns_security_rule_name", + dns_security_rule_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_update_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_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/dnsResolverPolicies/{dnsResolverPolicyName}/dnsSecurityRules/{dnsSecurityRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsSecurityRuleName": _SERIALIZER.url( + "dns_security_rule_name", + dns_security_rule_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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_delete_request( + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_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/dnsResolverPolicies/{dnsResolverPolicyName}/dnsSecurityRules/{dnsSecurityRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsSecurityRuleName": _SERIALIZER.url( + "dns_security_rule_name", + dns_security_rule_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**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, + dns_resolver_policy_name: str, + dns_security_rule_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/dnsResolverPolicies/{dnsResolverPolicyName}/dnsSecurityRules/{dnsSecurityRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + "dnsSecurityRuleName": _SERIALIZER.url( + "dns_security_rule_name", + dns_security_rule_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + dns_resolver_policy_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/dnsResolverPolicies/{dnsResolverPolicyName}/dnsSecurityRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsResolverPolicyName": _SERIALIZER.url( + "dns_resolver_policy_name", + dns_resolver_policy_name, + "str", + max_length=80, + min_length=1, + pattern=r"^[a-zA-Z0-9]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DnsSecurityRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_security_rules` 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, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRule, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsSecurityRule") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_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, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: _models.DnsSecurityRule, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRule + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. 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 + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRule, IO[bytes]], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Creates or updates a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + DnsSecurityRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRule or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 resource to be created, but to prevent updating + an existing resource. Other values will be ignored. Default value is None. + :type if_none_match: str + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsSecurityRule] = 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, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsSecurityRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsSecurityRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRulePatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = 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, "DnsSecurityRulePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: _models.DnsSecurityRulePatch, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRulePatch + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. 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 + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + parameters: Union[_models.DnsSecurityRulePatch, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.DnsSecurityRule]: + """Updates a DNS security rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param parameters: Parameters supplied to the Update operation. Is either a + DnsSecurityRulePatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.DnsSecurityRulePatch or IO[bytes] + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either DnsSecurityRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DnsSecurityRule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DnsSecurityRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DnsSecurityRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_policy_name: str, + dns_security_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS security rule for a DNS resolver policy. WARNING: 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 dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :param if_match: ETag of the resource. Omit this value to always overwrite the current + resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent + changes. Default value is None. + :type if_match: str + :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", self._config.api_version)) + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + 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[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, dns_resolver_policy_name: str, dns_security_rule_name: str, **kwargs: Any + ) -> _models.DnsSecurityRule: + """Gets properties of a DNS security rule for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param dns_security_rule_name: The name of the DNS security rule. Required. + :type dns_security_rule_name: str + :return: DnsSecurityRule or the result of cls(response) + :rtype: ~azure.mgmt.dnsresolver.models.DnsSecurityRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsSecurityRule] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + dns_security_rule_name=dns_security_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DnsSecurityRule", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, dns_resolver_policy_name: str, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.DnsSecurityRule"]: + """Lists DNS security rules for a DNS resolver policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param dns_resolver_policy_name: The name of the DNS resolver policy. Required. + :type dns_resolver_policy_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. Default value is None. + :type top: int + :return: An iterator like instance of either DnsSecurityRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsSecurityRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DnsSecurityRuleListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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( + resource_group_name=resource_group_name, + dns_resolver_policy_name=dns_resolver_policy_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsSecurityRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py index 4ba1b575e883..1ac03bdec96d 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,20 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +53,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -64,7 +63,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -72,7 +71,7 @@ def build_create_or_update_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,7 +100,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -111,7 +110,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -119,7 +118,7 @@ def build_update_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,7 +145,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +154,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -163,7 +162,7 @@ def build_delete_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +185,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +194,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -203,7 +202,7 @@ def build_get_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -225,7 +224,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -234,14 +233,14 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,7 +306,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -319,7 +317,7 @@ def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -336,7 +334,7 @@ def create_or_update( :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -347,7 +345,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -359,7 +356,7 @@ def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: Union[_models.ForwardingRule, IO], + parameters: Union[_models.ForwardingRule, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -373,9 +370,9 @@ def create_or_update( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + ForwardingRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -383,15 +380,11 @@ def create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -402,21 +395,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ForwardingRule] = 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, "ForwardingRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, @@ -427,15 +418,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -444,21 +434,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ForwardingRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } - @overload def update( self, @@ -489,7 +471,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -501,7 +482,7 @@ def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -517,7 +498,7 @@ def update( :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -525,7 +506,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -537,7 +517,7 @@ def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: Union[_models.ForwardingRulePatch, IO], + parameters: Union[_models.ForwardingRulePatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ForwardingRule: @@ -550,22 +530,18 @@ def update( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a ForwardingRulePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,21 +552,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ForwardingRule] = 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, "ForwardingRulePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, @@ -600,15 +574,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -617,16 +590,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -651,12 +620,11 @@ def delete( # pylint: disable=inconsistent-return-statements resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. :type if_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,27 +635,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -697,11 +662,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -716,12 +677,11 @@ def get( :type dns_forwarding_ruleset_name: str :param forwarding_rule_name: The name of the forwarding rule. Required. :type forwarding_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -732,26 +692,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ForwardingRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -760,16 +717,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ForwardingRule", pipeline_response) + deserialized = self._deserialize("ForwardingRule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -785,7 +738,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 ForwardingRule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.ForwardingRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -793,12 +745,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ForwardingRuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -809,18 +759,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -832,13 +780,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ForwardingRuleListResult", pipeline_response) @@ -848,10 +795,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -862,7 +810,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py index c027aa6dca99..afd0c3f86d15 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +57,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -66,7 +67,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -74,7 +75,7 @@ def build_create_or_update_request( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +104,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -113,7 +114,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -121,7 +122,7 @@ def build_update_request( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +149,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +158,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -165,7 +166,7 @@ def build_delete_request( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +185,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +194,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -201,7 +202,7 @@ def build_get_request( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -218,7 +219,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,14 +228,14 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -271,12 +272,12 @@ def _create_or_update_initial( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpoint, IO], + parameters: Union[_models.InboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.InboundEndpoint]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,21 +288,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.InboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "InboundEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -312,38 +311,33 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -379,14 +373,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -399,7 +385,7 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -416,7 +402,7 @@ def begin_create_or_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -427,14 +413,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -447,7 +425,7 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpoint, IO], + parameters: Union[_models.InboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -461,9 +439,9 @@ def begin_create_or_update( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + InboundEndpoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -471,17 +449,6 @@ def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -490,9 +457,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -513,12 +478,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -528,28 +494,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.InboundEndpoint].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/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return LROPoller[_models.InboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpointPatch, IO], + parameters: Union[_models.InboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.InboundEndpoint]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,21 +524,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.InboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "InboundEndpointPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -584,35 +546,33 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -644,14 +604,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -664,7 +616,7 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -680,7 +632,7 @@ def begin_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -688,14 +640,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -708,7 +652,7 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: Union[_models.InboundEndpointPatch, IO], + parameters: Union[_models.InboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.InboundEndpoint]: @@ -721,24 +665,13 @@ def begin_update( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + InboundEndpointPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] @@ -747,9 +680,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -769,12 +700,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -784,27 +716,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.InboundEndpoint].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return LROPoller[_models.InboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -815,41 +745,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -873,14 +805,6 @@ def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -888,15 +812,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, @@ -907,11 +829,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -920,17 +843,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -945,12 +864,11 @@ def get( :type dns_resolver_name: str :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. Required. :type inbound_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: InboundEndpoint or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.InboundEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -961,26 +879,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InboundEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -989,16 +904,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("InboundEndpoint", pipeline_response) + deserialized = self._deserialize("InboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -1014,7 +925,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 InboundEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,12 +932,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InboundEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1038,18 +946,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1061,13 +967,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("InboundEndpointListResult", pipeline_response) @@ -1077,10 +982,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1091,7 +997,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py index aaaad5eebd14..29193ccbb28f 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +57,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -66,7 +67,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -74,7 +75,7 @@ def build_create_or_update_request( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +104,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -113,7 +114,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -121,7 +122,7 @@ def build_update_request( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +149,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +158,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -165,7 +166,7 @@ def build_delete_request( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +185,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +194,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -201,7 +202,7 @@ def build_get_request( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -218,7 +219,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,14 +228,14 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -271,12 +272,12 @@ def _create_or_update_initial( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpoint, IO], + parameters: Union[_models.OutboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OutboundEndpoint]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,21 +288,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OutboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "OutboundEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -312,38 +311,33 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -380,14 +374,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -400,7 +386,7 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -418,7 +404,7 @@ def begin_create_or_update( Required. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -429,14 +415,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -449,7 +427,7 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpoint, IO], + parameters: Union[_models.OutboundEndpoint, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -464,9 +442,9 @@ def begin_create_or_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + OutboundEndpoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -474,17 +452,6 @@ def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -493,9 +460,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -516,12 +481,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -531,28 +497,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OutboundEndpoint].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/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return LROPoller[_models.OutboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpointPatch, IO], + parameters: Union[_models.OutboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OutboundEndpoint]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -563,21 +527,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OutboundEndpoint]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "OutboundEndpointPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -587,35 +549,33 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -648,14 +608,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -668,7 +620,7 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -685,7 +637,7 @@ def begin_update( Required. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -693,14 +645,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -713,7 +657,7 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: Union[_models.OutboundEndpointPatch, IO], + parameters: Union[_models.OutboundEndpointPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.OutboundEndpoint]: @@ -727,24 +671,13 @@ def begin_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + OutboundEndpointPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] @@ -753,9 +686,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -775,12 +706,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -790,27 +722,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OutboundEndpoint].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return LROPoller[_models.OutboundEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -821,41 +751,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -880,14 +812,6 @@ def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -895,15 +819,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, @@ -914,11 +836,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -927,17 +850,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -953,12 +872,11 @@ def get( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. Required. :type outbound_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OutboundEndpoint or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -969,26 +887,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -997,16 +912,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OutboundEndpoint", pipeline_response) + deserialized = self._deserialize("OutboundEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -1022,7 +933,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 OutboundEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,12 +940,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1046,18 +954,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1069,13 +975,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEndpointListResult", pipeline_response) @@ -1085,10 +990,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1099,7 +1005,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py index 331aca323cd0..1189a87d043f 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,12 +32,11 @@ from .. import models as _models 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +57,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -66,7 +67,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -74,7 +75,7 @@ def build_create_or_update_request( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +104,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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") @@ -113,7 +114,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -121,7 +122,7 @@ def build_update_request( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +149,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +158,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -165,7 +166,7 @@ def build_delete_request( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,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["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -197,7 +198,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -205,7 +206,7 @@ def build_get_request( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,7 +228,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -236,14 +237,14 @@ def build_list_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -280,12 +281,12 @@ def _create_or_update_initial( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLink, IO], + parameters: Union[_models.VirtualNetworkLink, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.VirtualNetworkLink]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,21 +297,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualNetworkLink]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "VirtualNetworkLink") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -321,38 +320,33 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -388,14 +382,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -408,7 +394,7 @@ def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -425,7 +411,7 @@ def begin_create_or_update( :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -436,14 +422,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -456,7 +434,7 @@ def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLink, IO], + parameters: Union[_models.VirtualNetworkLink, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -470,9 +448,9 @@ def begin_create_or_update( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink or IO + :param parameters: Parameters supplied to the CreateOrUpdate operation. Is either a + VirtualNetworkLink type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -480,17 +458,6 @@ def begin_create_or_update( :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating an existing resource. 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 - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -499,9 +466,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -522,12 +487,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -537,28 +503,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualNetworkLink].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/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return LROPoller[_models.VirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLinkPatch, IO], + parameters: Union[_models.VirtualNetworkLinkPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.VirtualNetworkLink]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,21 +533,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualNetworkLink]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = 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, "VirtualNetworkLinkPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -593,35 +555,33 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -653,14 +613,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -673,7 +625,7 @@ def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -689,7 +641,7 @@ def begin_update( :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str :param parameters: Parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes. Default value is None. @@ -697,14 +649,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -717,7 +661,7 @@ def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: Union[_models.VirtualNetworkLinkPatch, IO], + parameters: Union[_models.VirtualNetworkLinkPatch, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.VirtualNetworkLink]: @@ -730,24 +674,13 @@ def begin_update( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :param parameters: Parameters supplied to the Update operation. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch or IO + :param parameters: Parameters supplied to the Update operation. Is either a + VirtualNetworkLinkPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch or IO[bytes] :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. 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 - :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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] @@ -756,9 +689,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -778,12 +709,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -793,27 +725,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualNetworkLink].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_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return LROPoller[_models.VirtualNetworkLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -824,41 +754,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, subscription_id=self._config.subscription_id, if_match=if_match, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -883,14 +815,6 @@ def begin_delete( resource. Specify the last-seen ETag value to prevent accidentally overwriting 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: @@ -898,15 +822,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, @@ -917,11 +839,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -930,17 +853,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -955,12 +874,11 @@ def get( :type dns_forwarding_ruleset_name: str :param virtual_network_link_name: The name of the virtual network link. Required. :type virtual_network_link_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualNetworkLink or the result of cls(response) :rtype: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -971,26 +889,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkLink] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -999,16 +914,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualNetworkLink", pipeline_response) + deserialized = self._deserialize("VirtualNetworkLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -1024,7 +935,6 @@ def list( :param top: The maximum number of results to return. If not specified, returns up to 100 results. 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 VirtualNetworkLink or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :raises ~azure.core.exceptions.HttpResponseError: @@ -1032,12 +942,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-07-01"] = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkLinkListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1048,18 +956,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1071,13 +977,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkLinkListResult", pipeline_response) @@ -1087,10 +992,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1101,7 +1007,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks" - } diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/dev_requirements.txt b/sdk/dnsresolver/azure-mgmt-dnsresolver/dev_requirements.txt index 6ccb7f031ddd..6195bb36ac8e 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/dev_requirements.txt +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/dev_requirements.txt @@ -1 +1,2 @@ -e ../../../tools/azure-sdk-tools +aiohttp \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_delete.py index 00f6ae32e16c..7b5c585e8fd4 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.dns_forwarding_rulesets.begin_delete( + client.dns_forwarding_rulesets.begin_delete( resource_group_name="sampleResourceGroup", dns_forwarding_ruleset_name="samplednsForwardingRulesetName", ).result() - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_get.py index 750cf7710c52..b54a022e90d9 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_resource_group.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_resource_group.py index fe1e941ca453..2e1df2bce529 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_resource_group.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByResourceGroup.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_subscription.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_subscription.py index d26c34fae988..f9c187daf816 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_subscription.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListBySubscription.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_virtual_network.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_virtual_network.py index 70bccd99cb84..479cf212e9a8 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_virtual_network.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_list_by_virtual_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_ListByVirtualNetwork.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_patch.py index 8738460aaf81..c32a9c72d422 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_put.py index 4df57bfa514b..2172865eae09 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_forwarding_ruleset_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsForwardingRuleset_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsForwardingRuleset_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_delete.py index ccd5fe55b01c..a1c7f38ddf40 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.dns_resolvers.begin_delete( + client.dns_resolvers.begin_delete( resource_group_name="sampleResourceGroup", dns_resolver_name="sampleDnsResolver", ).result() - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_delete.py new file mode 100644 index 000000000000..6eda5cd7dc23 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + client.dns_resolver_domain_lists.begin_delete( + resource_group_name="sampleResourceGroup", + dns_resolver_domain_list_name="sampleDnsResolverDomainList", + ).result() + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_get.py new file mode 100644 index 000000000000..81c5446d3db4 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_domain_lists.get( + resource_group_name="sampleResourceGroup", + dns_resolver_domain_list_name="sampleDnsResolverDomainList", + ) + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_resource_group.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_resource_group.py new file mode 100644 index 000000000000..ee4daef5141a --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_domain_lists.list_by_resource_group( + resource_group_name="sampleResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_subscription.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_subscription.py new file mode 100644 index 000000000000..4e2aff1da791 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_list_by_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_domain_lists.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_patch.py new file mode 100644 index 000000000000..df6cc9f25c8f --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_patch.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_domain_lists.begin_update( + resource_group_name="sampleResourceGroup", + dns_resolver_domain_list_name="sampleDnsResolverDomainList", + parameters={"properties": {"domains": ["contoso.com"]}, "tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_put.py new file mode 100644 index 000000000000..36d8cc95bf81 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_domain_list_put.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_domain_list_put.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_domain_lists.begin_create_or_update( + resource_group_name="sampleResourceGroup", + dns_resolver_domain_list_name="sampleDnsResolverDomainList", + parameters={"location": "westus2", "properties": {"domains": ["contoso.com"]}, "tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverDomainList_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_get.py index 1d12ec025946..c37189174d8e 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_resource_group.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_resource_group.py index 757b5639cdf6..6d7d9f9d9925 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_resource_group.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByResourceGroup.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_subscription.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_subscription.py index 8d69c9a20dcb..252f426754e2 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_subscription.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListBySubscription.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_virtual_network.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_virtual_network.py index b20849024b41..6ab1eba768f1 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_virtual_network.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_list_by_virtual_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_ListByVirtualNetwork.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_ListByVirtualNetwork.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_patch.py index 0a9b27185f48..078ebd6d9f16 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_delete.py new file mode 100644 index 000000000000..f920999fb25e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + client.dns_resolver_policies.begin_delete( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + ).result() + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_get.py new file mode 100644 index 000000000000..bf2e13dc114c --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.get( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + ) + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_resource_group.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_resource_group.py new file mode 100644 index 000000000000..4b2e365c846b --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.list_by_resource_group( + resource_group_name="sampleResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_subscription.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_subscription.py new file mode 100644 index 000000000000..e574354fda40 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_list_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_virtual_network.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_virtual_network.py new file mode 100644 index 000000000000..32428fbff677 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_list_by_virtual_network.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_list_by_virtual_network.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.list_by_virtual_network( + resource_group_name="sampleResourceGroup", + virtual_network_name="sampleVirtualNetwork", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_ListByVirtualNetwork.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_patch.py new file mode 100644 index 000000000000..fa44c1aa844a --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_patch.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.begin_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + parameters={"tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_put.py new file mode 100644 index 000000000000..15ce3081e1af --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_put.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_put.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policies.begin_create_or_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + parameters={"location": "westus2", "tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicy_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_delete.py new file mode 100644 index 000000000000..46c6d3b3a2eb --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_virtual_network_link_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + client.dns_resolver_policy_virtual_network_links.begin_delete( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_resolver_policy_virtual_network_link_name="sampleVirtualNetworkLink", + ).result() + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicyVirtualNetworkLink_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_get.py new file mode 100644 index 000000000000..ccff24ef405d --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_virtual_network_link_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policy_virtual_network_links.get( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_resolver_policy_virtual_network_link_name="sampleVirtualNetworkLink", + ) + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicyVirtualNetworkLink_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_list.py new file mode 100644 index 000000000000..eeefc1022c38 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_virtual_network_link_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policy_virtual_network_links.list( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicyVirtualNetworkLink_List.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_patch.py new file mode 100644 index 000000000000..702c4d6cf736 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_patch.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_virtual_network_link_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policy_virtual_network_links.begin_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_resolver_policy_virtual_network_link_name="sampleVirtualNetworkLink", + parameters={"tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicyVirtualNetworkLink_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_put.py new file mode 100644 index 000000000000..a41444764392 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_policy_virtual_network_link_put.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_resolver_policy_virtual_network_link_put.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_resolver_policy_virtual_network_links.begin_create_or_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_resolver_policy_virtual_network_link_name="sampleVirtualNetworkLink", + parameters={ + "location": "westus2", + "properties": { + "virtualNetwork": { + "id": "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork" + } + }, + "tags": {"key1": "value1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolverPolicyVirtualNetworkLink_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_put.py index d62d166fd322..eca8e792f325 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_resolver_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/DnsResolver_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsResolver_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_delete.py new file mode 100644 index 000000000000..49c7dbd53a29 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_security_rule_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + client.dns_security_rules.begin_delete( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsDnsResolverPolicy", + dns_security_rule_name="sampleDnsSecurityRule", + ).result() + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsSecurityRule_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_get.py new file mode 100644 index 000000000000..b15545b321c2 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_security_rule_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_security_rules.get( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_security_rule_name="sampleDnsSecurityRule", + ) + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsSecurityRule_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_list.py new file mode 100644 index 000000000000..33271d4431f8 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_security_rule_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_security_rules.list( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsSecurityRule_List.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_patch.py new file mode 100644 index 000000000000..028ecbbbfbb7 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_patch.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_security_rule_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_security_rules.begin_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_security_rule_name="sampleDnsSecurityRule", + parameters={"properties": {"dnsSecurityRuleState": "Disabled"}, "tags": {"key1": "value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsSecurityRule_Patch.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_put.py new file mode 100644 index 000000000000..9d6b3d43e977 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/dns_security_rule_put.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dnsresolver +# USAGE + python dns_security_rule_put.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DnsResolverManagementClient( + credential=DefaultAzureCredential(), + subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", + ) + + response = client.dns_security_rules.begin_create_or_update( + resource_group_name="sampleResourceGroup", + dns_resolver_policy_name="sampleDnsResolverPolicy", + dns_security_rule_name="sampleDnsSecurityRule", + parameters={ + "location": "westus2", + "properties": { + "action": {"actionType": "Block", "blockResponseCode": "SERVFAIL"}, + "dnsResolverDomainLists": [ + { + "id": "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolverDomainLists/sampleDnsResolverDomainList" + } + ], + "dnsSecurityRuleState": "Enabled", + "priority": 100, + }, + "tags": {"key1": "value1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/DnsSecurityRule_Put.json +if __name__ == "__main__": + main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_delete.py index af33decff8c9..e6b72fdd4582 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.forwarding_rules.delete( + client.forwarding_rules.delete( resource_group_name="sampleResourceGroup", dns_forwarding_ruleset_name="sampleDnsForwardingRuleset", forwarding_rule_name="sampleForwardingRule", ) - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/ForwardingRule_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_get.py index bb8e1c6b241e..27b8b002894a 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/ForwardingRule_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_list.py index f2bea80061ef..f89fb1145deb 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_list.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_List.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/ForwardingRule_List.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_patch.py index ec4f07553633..7106479ab3cc 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/ForwardingRule_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_put.py index 90c04ec94502..fe98a13b8104 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/forwarding_rule_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/ForwardingRule_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/ForwardingRule_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_delete.py index a75717fd630e..18fdc79f3111 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.inbound_endpoints.begin_delete( + client.inbound_endpoints.begin_delete( resource_group_name="sampleResourceGroup", dns_resolver_name="sampleDnsResolver", inbound_endpoint_name="sampleInboundEndpoint", ).result() - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/InboundEndpoint_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_get.py index f343d8e94ab6..99d9b4f096af 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/InboundEndpoint_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_list.py index 6124781cc51f..718cdd0bfc96 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_list.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_List.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/InboundEndpoint_List.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_patch.py index c1a041027c71..be891c40295d 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/InboundEndpoint_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_put.py index d5336d43fb80..3c7ad07b56ad 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/inbound_endpoint_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/InboundEndpoint_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/InboundEndpoint_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_delete.py index 9d0989689fae..319473167d74 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.outbound_endpoints.begin_delete( + client.outbound_endpoints.begin_delete( resource_group_name="sampleResourceGroup", dns_resolver_name="sampleDnsResolver", outbound_endpoint_name="sampleOutboundEndpoint", ).result() - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/OutboundEndpoint_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_get.py index eb002d532603..9787449671ae 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/OutboundEndpoint_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_list.py index ca9b45cdd213..656543f0eb02 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_list.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_List.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/OutboundEndpoint_List.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_patch.py index b930197f04f8..8b813847bae7 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/OutboundEndpoint_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_put.py index 923a99eaccf8..0147e3fdddf9 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/outbound_endpoint_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/OutboundEndpoint_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/OutboundEndpoint_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_delete.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_delete.py index 5ee7a89be957..b5771533109a 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_delete.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="abdd4249-9f34-4cc6-8e42-c2e32110603e", ) - response = client.virtual_network_links.begin_delete( + client.virtual_network_links.begin_delete( resource_group_name="sampleResourceGroup", dns_forwarding_ruleset_name="sampleDnsForwardingRuleset", virtual_network_link_name="sampleVirtualNetworkLink", ).result() - print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Delete.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/VirtualNetworkLink_Delete.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_get.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_get.py index 05a840773e20..9259d3e7ecc3 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_get.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Get.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/VirtualNetworkLink_Get.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_list.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_list.py index 725cd9e7ffbe..a7e02aa6c6cd 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_list.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_List.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/VirtualNetworkLink_List.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_patch.py index 10f380c0b595..250496acfe3a 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_patch.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Patch.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/VirtualNetworkLink_Patch.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_put.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_put.py index bcf7c2f4e26b..aa3f16348c94 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_put.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_samples/virtual_network_link_put.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dnsresolver import DnsResolverManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/stable/2022-07-01/examples/VirtualNetworkLink_Put.json +# x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2023-07-01-preview/examples/VirtualNetworkLink_Put.json if __name__ == "__main__": main() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/conftest.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/conftest.py new file mode 100644 index 000000000000..a2e5e348907a --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/conftest.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + dnsresolvermanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + dnsresolvermanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + dnsresolvermanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + dnsresolvermanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=dnsresolvermanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=dnsresolvermanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsresolvermanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsresolvermanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations.py new file mode 100644 index 000000000000..c8da80a43f7b --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsForwardingRulesetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_forwarding_rulesets.begin_create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + parameters={ + "dnsResolverOutboundEndpoints": [{"id": "str"}], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_forwarding_rulesets.begin_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + parameters={"dnsResolverOutboundEndpoints": [{"id": "str"}], "tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_forwarding_rulesets.begin_delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_forwarding_rulesets.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_forwarding_rulesets.list( + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async.py new file mode 100644 index 000000000000..4571bd150400 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsForwardingRulesetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_forwarding_rulesets.begin_create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + parameters={ + "dnsResolverOutboundEndpoints": [{"id": "str"}], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_forwarding_rulesets.begin_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + parameters={"dnsResolverOutboundEndpoints": [{"id": "str"}], "tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_forwarding_rulesets.begin_delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_forwarding_rulesets.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_forwarding_rulesets.list( + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations.py new file mode 100644 index 000000000000..59a64fbd4202 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverDomainListsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_resolver_domain_lists.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + parameters={ + "domains": ["str"], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_resolver_domain_lists.begin_update( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + parameters={"domains": ["str"], "tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_resolver_domain_lists.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_resolver_domain_lists.get( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_domain_lists.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolver_domain_lists.list( + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async.py new file mode 100644 index 000000000000..dfd039fd0d38 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverDomainListsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_resolver_domain_lists.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + parameters={ + "domains": ["str"], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_resolver_domain_lists.begin_update( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + parameters={"domains": ["str"], "tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_resolver_domain_lists.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_resolver_domain_lists.get( + resource_group_name=resource_group.name, + dns_resolver_domain_list_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_domain_lists.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolver_domain_lists.list( + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations.py new file mode 100644 index 000000000000..4f43e057a4cb --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_resolver_policies.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + parameters={ + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_resolver_policies.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_resolver_policies.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_resolver_policies.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_policies.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolver_policies.list( + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_resolver_policies.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations_async.py new file mode 100644 index 000000000000..d87ed2b4af1d --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policies_operations_async.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_resolver_policies.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + parameters={ + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_resolver_policies.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_resolver_policies.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_resolver_policies.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_policies.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolver_policies.list( + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_resolver_policies.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations.py new file mode 100644 index 000000000000..fbe68ce481e8 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverPolicyVirtualNetworkLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + parameters={ + "location": "str", + "virtualNetwork": {"id": "str"}, + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.list( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations_async.py new file mode 100644 index 000000000000..adecb5d4652e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolver_policy_virtual_network_links_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolverPolicyVirtualNetworkLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_resolver_policy_virtual_network_links.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + parameters={ + "location": "str", + "virtualNetwork": {"id": "str"}, + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_resolver_policy_virtual_network_links.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_resolver_policy_virtual_network_links.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_resolver_policy_virtual_network_links.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_resolver_policy_virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolver_policy_virtual_network_links.list( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations.py new file mode 100644 index 000000000000..968798c9f5f3 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolversOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_resolvers.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + parameters={ + "location": "str", + "virtualNetwork": {"id": "str"}, + "dnsResolverState": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_resolvers.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_resolvers.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_resolvers.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolvers.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolvers.list( + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_resolvers.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations_async.py new file mode 100644 index 000000000000..7b33d616dba3 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_resolvers_operations_async.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsResolversOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_resolvers.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + parameters={ + "location": "str", + "virtualNetwork": {"id": "str"}, + "dnsResolverState": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_resolvers.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_resolvers.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_resolvers.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolvers.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolvers.list( + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_virtual_network(self, resource_group): + response = self.client.dns_resolvers.list_by_virtual_network( + resource_group_name=resource_group.name, + virtual_network_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations.py new file mode 100644 index 000000000000..751e325da29f --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsSecurityRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dns_security_rules.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + parameters={ + "action": {"actionType": "str", "blockResponseCode": "str"}, + "dnsResolverDomainLists": [{"id": "str"}], + "location": "str", + "priority": 0, + "dnsSecurityRuleState": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dns_security_rules.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + parameters={ + "action": {"actionType": "str", "blockResponseCode": "str"}, + "dnsResolverDomainLists": [{"id": "str"}], + "dnsSecurityRuleState": "str", + "priority": 0, + "tags": {"str": "str"}, + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dns_security_rules.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dns_security_rules.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_security_rules.list( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations_async.py new file mode 100644 index 000000000000..bebd4f605c6d --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_dns_security_rules_operations_async.py @@ -0,0 +1,118 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementDnsSecurityRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dns_security_rules.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + parameters={ + "action": {"actionType": "str", "blockResponseCode": "str"}, + "dnsResolverDomainLists": [{"id": "str"}], + "location": "str", + "priority": 0, + "dnsSecurityRuleState": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dns_security_rules.begin_update( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + parameters={ + "action": {"actionType": "str", "blockResponseCode": "str"}, + "dnsResolverDomainLists": [{"id": "str"}], + "dnsSecurityRuleState": "str", + "priority": 0, + "tags": {"str": "str"}, + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dns_security_rules.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dns_security_rules.get( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + dns_security_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_security_rules.list( + resource_group_name=resource_group.name, + dns_resolver_policy_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations.py new file mode 100644 index 000000000000..2bffe98ecd08 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementForwardingRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.forwarding_rules.create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + parameters={ + "domainName": "str", + "targetDnsServers": [{"ipAddress": "str", "port": 53}], + "etag": "str", + "forwardingRuleState": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.forwarding_rules.update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + parameters={ + "forwardingRuleState": "str", + "metadata": {"str": "str"}, + "targetDnsServers": [{"ipAddress": "str", "port": 53}], + }, + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.forwarding_rules.delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.forwarding_rules.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.forwarding_rules.list( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations_async.py new file mode 100644 index 000000000000..6718ef350346 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_forwarding_rules_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementForwardingRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.forwarding_rules.create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + parameters={ + "domainName": "str", + "targetDnsServers": [{"ipAddress": "str", "port": 53}], + "etag": "str", + "forwardingRuleState": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.forwarding_rules.update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + parameters={ + "forwardingRuleState": "str", + "metadata": {"str": "str"}, + "targetDnsServers": [{"ipAddress": "str", "port": 53}], + }, + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.forwarding_rules.delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.forwarding_rules.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + forwarding_rule_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.forwarding_rules.list( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations.py new file mode 100644 index 000000000000..bed1eba9d838 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementInboundEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.inbound_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + parameters={ + "ipConfigurations": [ + {"subnet": {"id": "str"}, "privateIpAddress": "str", "privateIpAllocationMethod": "Dynamic"} + ], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.inbound_endpoints.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.inbound_endpoints.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.inbound_endpoints.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.inbound_endpoints.list( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations_async.py new file mode 100644 index 000000000000..55dd9d066ad6 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_inbound_endpoints_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementInboundEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.inbound_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + parameters={ + "ipConfigurations": [ + {"subnet": {"id": "str"}, "privateIpAddress": "str", "privateIpAllocationMethod": "Dynamic"} + ], + "location": "str", + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.inbound_endpoints.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.inbound_endpoints.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.inbound_endpoints.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + inbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.inbound_endpoints.list( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations.py new file mode 100644 index 000000000000..74a2072b509b --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementOutboundEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.outbound_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + parameters={ + "location": "str", + "subnet": {"id": "str"}, + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.outbound_endpoints.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.outbound_endpoints.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.outbound_endpoints.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.outbound_endpoints.list( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations_async.py new file mode 100644 index 000000000000..7b58165f6309 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_outbound_endpoints_operations_async.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementOutboundEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.outbound_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + parameters={ + "location": "str", + "subnet": {"id": "str"}, + "etag": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "resourceGuid": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.outbound_endpoints.begin_update( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.outbound_endpoints.begin_delete( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.outbound_endpoints.get( + resource_group_name=resource_group.name, + dns_resolver_name="str", + outbound_endpoint_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.outbound_endpoints.list( + resource_group_name=resource_group.name, + dns_resolver_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations.py new file mode 100644 index 000000000000..3115fd5205f1 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementVirtualNetworkLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.virtual_network_links.begin_create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + parameters={ + "virtualNetwork": {"id": "str"}, + "etag": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.virtual_network_links.begin_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + parameters={"metadata": {"str": "str"}}, + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.virtual_network_links.begin_delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + api_version="2023-07-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.virtual_network_links.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.virtual_network_links.list( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations_async.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations_async.py new file mode 100644 index 000000000000..5c1d88dcc2bf --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/generated_tests/test_dns_resolver_management_virtual_network_links_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDnsResolverManagementVirtualNetworkLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.virtual_network_links.begin_create_or_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + parameters={ + "virtualNetwork": {"id": "str"}, + "etag": "str", + "id": "str", + "metadata": {"str": "str"}, + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.virtual_network_links.begin_update( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + parameters={"metadata": {"str": "str"}}, + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.virtual_network_links.begin_delete( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.virtual_network_links.get( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + virtual_network_link_name="str", + api_version="2023-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.virtual_network_links.list( + resource_group_name=resource_group.name, + dns_forwarding_ruleset_name="str", + api_version="2023-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py index 60e77ee65563..54a04b3fb8b6 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Dnsresolver Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", ) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/conftest.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/conftest.py new file mode 100644 index 000000000000..a2e5e348907a --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/conftest.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + dnsresolvermanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + dnsresolvermanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + dnsresolvermanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + dnsresolvermanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=dnsresolvermanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=dnsresolvermanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsresolvermanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dnsresolvermanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async_test.py new file mode 100644 index 000000000000..71ba5e98fe7c --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_async_test.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsForwardingRulesetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_forwarding_rulesets.list() + result = [r async for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_test.py new file mode 100644 index 000000000000..98d1c250338b --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_forwarding_rulesets_operations_test.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsForwardingRulesetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_forwarding_rulesets.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_forwarding_rulesets.list() + result = [r for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async_test.py new file mode 100644 index 000000000000..263eed5bbcdb --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_async_test.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolverDomainListsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_domain_lists.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolver_domain_lists.list() + result = [r async for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_test.py new file mode 100644 index 000000000000..a079af77cb27 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_domain_lists_operations_test.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolverDomainListsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_domain_lists.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolver_domain_lists.list() + result = [r for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_async_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_async_test.py new file mode 100644 index 000000000000..91800abedad7 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_async_test.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolverPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_policies.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolver_policies.list() + result = [r async for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_test.py new file mode 100644 index 000000000000..9543bf79782e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolver_policies_operations_test.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolverPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolver_policies.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolver_policies.list() + result = [r for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_async_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_async_test.py new file mode 100644 index 000000000000..37447a4c39a0 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_async_test.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver.aio import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolversOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolvers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dns_resolvers.list() + result = [r async for r in response] + assert response + \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_test.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_test.py new file mode 100644 index 000000000000..1f83a475a077 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/tests/test_dns_resolver_management_dns_resolvers_operations_test.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dnsresolver import DnsResolverManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestDnsResolverManagementDnsResolversOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DnsResolverManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dns_resolvers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dns_resolvers.list() + result = [r for r in response] + assert response + \ No newline at end of file