diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md b/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/LICENSE b/sdk/dnsresolver/azure-mgmt-dnsresolver/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/MANIFEST.in b/sdk/dnsresolver/azure-mgmt-dnsresolver/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md b/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md new file mode 100644 index 000000000000..d68b3a690f0d --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.7+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +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 new file mode 100644 index 000000000000..710e43fc78f1 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "585d53dcffbf210ba2d9862f421e4a40947b34ae", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/dnsresolver/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/dnsresolver/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py new file mode 100644 index 000000000000..c5378e850db8 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_resolver_management_client import DnsResolverManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['DnsResolverManagementClient'] + +# `._patch.py` 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 +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py new file mode 100644 index 000000000000..aa80881f1a07 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DnsResolverManagementClientConfiguration(Configuration): + """Configuration for DnsResolverManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-04-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dnsresolver/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/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 new file mode 100644 index 000000000000..7f389b0e6ddf --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import DnsResolverManagementClientConfiguration +from .operations import DnsForwardingRulesetsOperations, DnsResolversOperations, ForwardingRulesOperations, InboundEndpointsOperations, OutboundEndpointsOperations, VirtualNetworkLinksOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class DnsResolverManagementClient: + """The DNS Resolver Management Client. + + :ivar dns_resolvers: DnsResolversOperations operations + :vartype dns_resolvers: dns_resolver_management_client.operations.DnsResolversOperations + :ivar inbound_endpoints: InboundEndpointsOperations operations + :vartype inbound_endpoints: + dns_resolver_management_client.operations.InboundEndpointsOperations + :ivar outbound_endpoints: OutboundEndpointsOperations operations + :vartype outbound_endpoints: + dns_resolver_management_client.operations.OutboundEndpointsOperations + :ivar dns_forwarding_rulesets: DnsForwardingRulesetsOperations operations + :vartype dns_forwarding_rulesets: + dns_resolver_management_client.operations.DnsForwardingRulesetsOperations + :ivar forwarding_rules: ForwardingRulesOperations operations + :vartype forwarding_rules: dns_resolver_management_client.operations.ForwardingRulesOperations + :ivar virtual_network_links: VirtualNetworkLinksOperations operations + :vartype virtual_network_links: + dns_resolver_management_client.operations.VirtualNetworkLinksOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsResolverManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.dns_resolvers = DnsResolversOperations(self._client, self._config, self._serialize, self._deserialize) + self.inbound_endpoints = InboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_endpoints = OutboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.forwarding_rules = ForwardingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_network_links = VirtualNetworkLinksOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DnsResolverManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json new file mode 100644 index 000000000000..f53b47be216e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2020-04-01-preview", + "total_api_version_list": ["2020-04-01-preview"], + "client": { + "name": "DnsResolverManagementClient", + "filename": "_dns_resolver_management_client", + "description": "The DNS Resolver Management Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsResolverManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsResolverManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "dns_resolvers": "DnsResolversOperations", + "inbound_endpoints": "InboundEndpointsOperations", + "outbound_endpoints": "OutboundEndpointsOperations", + "dns_forwarding_rulesets": "DnsForwardingRulesetsOperations", + "forwarding_rules": "ForwardingRulesOperations", + "virtual_network_links": "VirtualNetworkLinksOperations" + } +} \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# 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(): + pass \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py new file mode 100644 index 000000000000..60222ade089f --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_resolver_management_client import DnsResolverManagementClient +__all__ = ['DnsResolverManagementClient'] + +# `._patch.py` 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 +from ._patch import patch_sdk +patch_sdk() 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 new file mode 100644 index 000000000000..8b6c7fd3310e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DnsResolverManagementClientConfiguration(Configuration): + """Configuration for DnsResolverManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-04-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dnsresolver/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/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 new file mode 100644 index 000000000000..69292fa1c1ce --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import DnsResolverManagementClientConfiguration +from .operations import DnsForwardingRulesetsOperations, DnsResolversOperations, ForwardingRulesOperations, InboundEndpointsOperations, OutboundEndpointsOperations, VirtualNetworkLinksOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class DnsResolverManagementClient: + """The DNS Resolver Management Client. + + :ivar dns_resolvers: DnsResolversOperations operations + :vartype dns_resolvers: dns_resolver_management_client.aio.operations.DnsResolversOperations + :ivar inbound_endpoints: InboundEndpointsOperations operations + :vartype inbound_endpoints: + dns_resolver_management_client.aio.operations.InboundEndpointsOperations + :ivar outbound_endpoints: OutboundEndpointsOperations operations + :vartype outbound_endpoints: + dns_resolver_management_client.aio.operations.OutboundEndpointsOperations + :ivar dns_forwarding_rulesets: DnsForwardingRulesetsOperations operations + :vartype dns_forwarding_rulesets: + dns_resolver_management_client.aio.operations.DnsForwardingRulesetsOperations + :ivar forwarding_rules: ForwardingRulesOperations operations + :vartype forwarding_rules: + dns_resolver_management_client.aio.operations.ForwardingRulesOperations + :ivar virtual_network_links: VirtualNetworkLinksOperations operations + :vartype virtual_network_links: + dns_resolver_management_client.aio.operations.VirtualNetworkLinksOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsResolverManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.dns_resolvers = DnsResolversOperations(self._client, self._config, self._serialize, self._deserialize) + self.inbound_endpoints = InboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_endpoints = OutboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.forwarding_rules = ForwardingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_network_links = VirtualNetworkLinksOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DnsResolverManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# 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(): + pass \ No newline at end of file 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 new file mode 100644 index 000000000000..6656675bef07 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_resolvers_operations import DnsResolversOperations +from ._inbound_endpoints_operations import InboundEndpointsOperations +from ._outbound_endpoints_operations import OutboundEndpointsOperations +from ._dns_forwarding_rulesets_operations import DnsForwardingRulesetsOperations +from ._forwarding_rules_operations import ForwardingRulesOperations +from ._virtual_network_links_operations import VirtualNetworkLinksOperations + +__all__ = [ + 'DnsResolversOperations', + 'InboundEndpointsOperations', + 'OutboundEndpointsOperations', + 'DnsForwardingRulesetsOperations', + 'ForwardingRulesOperations', + 'VirtualNetworkLinksOperations', +] 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 new file mode 100644 index 000000000000..cc5966db1b25 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py @@ -0,0 +1,697 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dns_forwarding_rulesets_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_virtual_network_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DnsForwardingRulesetsOperations: + """DnsForwardingRulesetsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRuleset", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsForwardingRuleset"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsForwardingRuleset') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRuleset", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.DnsForwardingRuleset"]: + """Creates or updates a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.DnsForwardingRuleset + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DnsForwardingRuleset or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRulesetPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsForwardingRuleset"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsForwardingRulesetPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRulesetPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.DnsForwardingRuleset"]: + """Updates a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.DnsForwardingRulesetPatch + :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. + :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 DnsForwardingRuleset or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding + rules within the ruleset will be deleted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + **kwargs: Any + ) -> "_models.DnsForwardingRuleset": + """Gets a DNS forwarding ruleset properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :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: ~dns_resolver_management_client.models.DnsForwardingRuleset + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DnsForwardingRulesetListResult"]: + """Lists DNS forwarding rulesets within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsForwardingRulesetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + + @distributed_trace + def list( + self, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DnsForwardingRulesetListResult"]: + """Lists DNS forwarding rulesets in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsForwardingRulesetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + + @distributed_trace + def list_by_virtual_network( + self, + resource_group_name: str, + virtual_network_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkDnsForwardingRulesetListResult"]: + """Lists DNS forwarding ruleset resource IDs attached to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. + :type virtual_network_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 VirtualNetworkDnsForwardingRulesetListResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkDnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=self.list_by_virtual_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkDnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets'} # type: ignore 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 new file mode 100644 index 000000000000..53df75f1cc7b --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py @@ -0,0 +1,694 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dns_resolvers_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_virtual_network_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DnsResolversOperations: + """DnsResolversOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolver", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsResolver"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResolver') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolver", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.DnsResolver"]: + """Creates or updates a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.DnsResolver + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DnsResolver or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsResolver] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsResolver', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolverPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsResolver"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResolverPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DnsResolver', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolverPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.DnsResolver"]: + """Updates a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.DnsResolverPatch + :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. + :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 DnsResolver or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsResolver] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsResolver', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_resolver_name: str, + **kwargs: Any + ) -> "_models.DnsResolver": + """Gets properties of a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :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: ~dns_resolver_management_client.models.DnsResolver + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DnsResolver', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DnsResolverListResult"]: + """Lists DNS resolvers within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsResolverListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + + @distributed_trace + def list( + self, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DnsResolverListResult"]: + """Lists DNS resolvers in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsResolverListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + + @distributed_trace + def list_by_virtual_network( + self, + resource_group_name: str, + virtual_network_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SubResourceListResult"]: + """Lists DNS resolver resource IDs linked to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. + :type virtual_network_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 SubResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.SubResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=self.list_by_virtual_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SubResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers'} # type: ignore 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 new file mode 100644 index 000000000000..074c4f8a108d --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py @@ -0,0 +1,388 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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, build_get_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ForwardingRulesOperations: + """ForwardingRulesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + parameters: "_models.ForwardingRule", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Creates or updates a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.ForwardingRule + :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. + :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. + :type if_none_match: 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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForwardingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + parameters: "_models.ForwardingRulePatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Updates a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_rule_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.ForwardingRulePatch + :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. + :type if_match: 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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForwardingRulePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be + undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Gets properties of a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ForwardingRuleListResult"]: + """Lists forwarding rules in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 ForwardingRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.ForwardingRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ForwardingRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules'} # type: ignore 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 new file mode 100644 index 000000000000..5dadba3dec11 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py @@ -0,0 +1,571 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._inbound_endpoints_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InboundEndpointsOperations: + """InboundEndpointsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.InboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InboundEndpoint') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.InboundEndpoint"]: + """Creates or updates an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.InboundEndpoint + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either InboundEndpoint or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.InboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InboundEndpointPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.InboundEndpoint"]: + """Updates an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.InboundEndpointPatch + :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. + :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 InboundEndpoint or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + 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: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + **kwargs: Any + ) -> "_models.InboundEndpoint": + """Gets properties of an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :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: ~dns_resolver_management_client.models.InboundEndpoint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_resolver_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.InboundEndpointListResult"]: + """Lists inbound endpoints for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 InboundEndpointListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.InboundEndpointListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpointListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("InboundEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints'} # type: ignore 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 new file mode 100644 index 000000000000..8ad36befea6e --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py @@ -0,0 +1,571 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._outbound_endpoints_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OutboundEndpointsOperations: + """OutboundEndpointsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.OutboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OutboundEndpoint') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.OutboundEndpoint"]: + """Creates or updates an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.OutboundEndpoint + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OutboundEndpoint or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.OutboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OutboundEndpointPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.OutboundEndpoint"]: + """Updates an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.OutboundEndpointPatch + :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. + :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 OutboundEndpoint or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + 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: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + **kwargs: Any + ) -> "_models.OutboundEndpoint": + """Gets properties of an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :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: ~dns_resolver_management_client.models.OutboundEndpoint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_resolver_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.OutboundEndpointListResult"]: + """Lists outbound endpoints for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 OutboundEndpointListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.OutboundEndpointListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpointListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OutboundEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints'} # type: ignore 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 new file mode 100644 index 000000000000..7bc901dd15a4 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py @@ -0,0 +1,572 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_network_links_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualNetworkLinksOperations: + """VirtualNetworkLinksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLink", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.VirtualNetworkLink"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkLink') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLink", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualNetworkLink"]: + """Creates or updates a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLink + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualNetworkLink or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLinkPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.VirtualNetworkLink"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkLinkPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLinkPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.VirtualNetworkLink"]: + """Updates a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLinkPatch + :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. + :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 VirtualNetworkLink or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + 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: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be + undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type 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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + 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, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + **kwargs: Any + ) -> "_models.VirtualNetworkLink": + """Gets properties of a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :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: ~dns_resolver_management_client.models.VirtualNetworkLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkLinkListResult"]: + """Lists virtual network links to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 VirtualNetworkLinkListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.VirtualNetworkLinkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLinkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkLinkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks'} # type: ignore 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 new file mode 100644 index 000000000000..dbfbfbf78a28 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import CloudErrorBody +from ._models_py3 import DnsForwardingRuleset +from ._models_py3 import DnsForwardingRulesetListResult +from ._models_py3 import DnsForwardingRulesetPatch +from ._models_py3 import DnsResolver +from ._models_py3 import DnsResolverListResult +from ._models_py3 import DnsResolverPatch +from ._models_py3 import ForwardingRule +from ._models_py3 import ForwardingRuleListResult +from ._models_py3 import ForwardingRulePatch +from ._models_py3 import InboundEndpoint +from ._models_py3 import InboundEndpointListResult +from ._models_py3 import InboundEndpointPatch +from ._models_py3 import IpConfiguration +from ._models_py3 import OutboundEndpoint +from ._models_py3 import OutboundEndpointListResult +from ._models_py3 import OutboundEndpointPatch +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SubResource +from ._models_py3 import SubResourceListResult +from ._models_py3 import SystemData +from ._models_py3 import TargetDnsServer +from ._models_py3 import TrackedResource +from ._models_py3 import VirtualNetworkDnsForwardingRuleset +from ._models_py3 import VirtualNetworkDnsForwardingRulesetListResult +from ._models_py3 import VirtualNetworkLink +from ._models_py3 import VirtualNetworkLinkListResult +from ._models_py3 import VirtualNetworkLinkPatch + + +from ._dns_resolver_management_client_enums import ( + CreatedByType, + DnsResolverState, + ForwardingRuleState, + IpAllocationMethod, + ProvisioningState, +) + +__all__ = [ + 'CloudErrorBody', + 'DnsForwardingRuleset', + 'DnsForwardingRulesetListResult', + 'DnsForwardingRulesetPatch', + 'DnsResolver', + 'DnsResolverListResult', + 'DnsResolverPatch', + 'ForwardingRule', + 'ForwardingRuleListResult', + 'ForwardingRulePatch', + 'InboundEndpoint', + 'InboundEndpointListResult', + 'InboundEndpointPatch', + 'IpConfiguration', + 'OutboundEndpoint', + 'OutboundEndpointListResult', + 'OutboundEndpointPatch', + 'ProxyResource', + 'Resource', + 'SubResource', + 'SubResourceListResult', + 'SystemData', + 'TargetDnsServer', + 'TrackedResource', + 'VirtualNetworkDnsForwardingRuleset', + 'VirtualNetworkDnsForwardingRulesetListResult', + 'VirtualNetworkLink', + 'VirtualNetworkLinkListResult', + 'VirtualNetworkLinkPatch', + 'CreatedByType', + 'DnsResolverState', + '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 new file mode 100644 index 000000000000..68eb47d397ea --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DnsResolverState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The current status of the DNS resolver. This is a read-only property and any attempt to set + this value will be ignored. + """ + + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + +class ForwardingRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The state of forwarding rule. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class IpAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Private IP address allocation method. + """ + + STATIC = "Static" + DYNAMIC = "Dynamic" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The current provisioning state of the resource. + """ + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" 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 new file mode 100644 index 000000000000..d4fbc6749f77 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py @@ -0,0 +1,1329 @@ +# 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 datetime +from typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._dns_resolver_management_client_enums import * + + +class CloudErrorBody(msrest.serialization.Model): + """The body of an error message. + + :ivar code: The error code. + :vartype code: str + :ivar message: A description of what caused the error. + :vartype message: str + :ivar target: The target resource of the error message. + :vartype target: str + :ivar details: Extra error information. + :vartype details: list[~dns_resolver_management_client.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: The error code. + :paramtype code: str + :keyword message: A description of what caused the error. + :paramtype message: str + :keyword target: The target resource of the error message. + :paramtype target: str + :keyword details: Extra error information. + :paramtype details: list[~dns_resolver_management_client.models.CloudErrorBody] + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + 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}. + :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 + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """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. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class DnsForwardingRuleset(TrackedResource): + """Describes a DNS forwarding ruleset. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :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: ~dns_resolver_management_client.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. + :vartype dns_resolver_outbound_endpoints: + list[~dns_resolver_management_client.models.SubResource] + :ivar provisioning_state: The current provisioning state of the DNS forwarding ruleset. This is + a read-only property and any attempt to set this value will be ignored. Possible values + include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :ivar resource_guid: The resourceGuid for the DNS forwarding ruleset. + :vartype resource_guid: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'etag': {'readonly': True}, + 'system_data': {'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'}, + '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'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + dns_resolver_outbound_endpoints: Optional[List["SubResource"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :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 + DNS servers. + :paramtype dns_resolver_outbound_endpoints: + list[~dns_resolver_management_client.models.SubResource] + """ + super(DnsForwardingRuleset, self).__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 + + +class DnsForwardingRulesetListResult(msrest.serialization.Model): + """The response to an enumeration operation on DNS forwarding rulesets. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS forwarding rulesets. + :vartype value: list[~dns_resolver_management_client.models.DnsForwardingRuleset] + :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': '[DnsForwardingRuleset]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DnsForwardingRuleset"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the DNS forwarding rulesets. + :paramtype value: list[~dns_resolver_management_client.models.DnsForwardingRuleset] + """ + super(DnsForwardingRulesetListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DnsForwardingRulesetPatch(msrest.serialization.Model): + """Describes a DNS forwarding ruleset PATCH operation. + + :ivar tags: A set of tags. Tags for DNS Resolver. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags for DNS Resolver. + :paramtype tags: dict[str, str] + """ + super(DnsForwardingRulesetPatch, self).__init__(**kwargs) + self.tags = tags + + +class DnsResolver(TrackedResource): + """Describes a DNS resolver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :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: ~dns_resolver_management_client.models.SystemData + :ivar virtual_network: The reference to the virtual network. This cannot be changed after + creation. + :vartype virtual_network: ~dns_resolver_management_client.models.SubResource + :ivar dns_resolver_state: The current status of the DNS resolver. This is a read-only property + and any attempt to set this value will be ignored. Possible values include: "Connected", + "Disconnected". + :vartype dns_resolver_state: str or ~dns_resolver_management_client.models.DnsResolverState + :ivar provisioning_state: The current provisioning state of the DNS resolver. This is a + read-only property and any attempt to set this value will be ignored. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :ivar resource_guid: The resourceGuid property of the DNS resolver resource. + :vartype resource_guid: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'etag': {'readonly': True}, + 'system_data': {'readonly': True}, + 'dns_resolver_state': {'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'}, + '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'}, + 'resource_guid': {'key': 'properties.resourceGuid', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + virtual_network: Optional["SubResource"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword virtual_network: The reference to the virtual network. This cannot be changed after + creation. + :paramtype virtual_network: ~dns_resolver_management_client.models.SubResource + """ + super(DnsResolver, self).__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 DnsResolverListResult(msrest.serialization.Model): + """The response to an enumeration operation on DNS resolvers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the DNS resolvers. + :vartype value: list[~dns_resolver_management_client.models.DnsResolver] + :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': '[DnsResolver]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DnsResolver"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the DNS resolvers. + :paramtype value: list[~dns_resolver_management_client.models.DnsResolver] + """ + super(DnsResolverListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DnsResolverPatch(msrest.serialization.Model): + """Describes a DNS resolver for PATCH operation. + + :ivar tags: A set of tags. Tags for DNS Resolver. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags for DNS Resolver. + :paramtype tags: dict[str, str] + """ + super(DnsResolverPatch, self).__init__(**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. + + 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}. + :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 + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class ForwardingRule(ProxyResource): + """Describes a forwarding rule within a DNS forwarding ruleset. + + 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}. + :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 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: ~dns_resolver_management_client.models.SystemData + :ivar domain_name: The domain name for the forwarding rule. + :vartype domain_name: str + :ivar target_dns_servers: DNS servers to forward the DNS query to. + :vartype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :ivar metadata: Metadata attached to the forwarding rule. + :vartype metadata: dict[str, str] + :ivar forwarding_rule_state: The state of forwarding rule. Possible values include: "Enabled", + "Disabled". + :vartype forwarding_rule_state: str or + ~dns_resolver_management_client.models.ForwardingRuleState + :ivar provisioning_state: The current provisioning state of the forwarding rule. This is a + read-only property and any attempt to set this value will be ignored. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'domain_name': {'key': 'properties.domainName', 'type': 'str'}, + 'target_dns_servers': {'key': 'properties.targetDnsServers', 'type': '[TargetDnsServer]'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'forwarding_rule_state': {'key': 'properties.forwardingRuleState', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + domain_name: Optional[str] = None, + target_dns_servers: Optional[List["TargetDnsServer"]] = None, + metadata: Optional[Dict[str, str]] = None, + forwarding_rule_state: Optional[Union[str, "ForwardingRuleState"]] = None, + **kwargs + ): + """ + :keyword domain_name: The domain name for the forwarding rule. + :paramtype domain_name: str + :keyword target_dns_servers: DNS servers to forward the DNS query to. + :paramtype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :keyword metadata: Metadata attached to the forwarding rule. + :paramtype metadata: dict[str, str] + :keyword forwarding_rule_state: The state of forwarding rule. Possible values include: + "Enabled", "Disabled". + :paramtype forwarding_rule_state: str or + ~dns_resolver_management_client.models.ForwardingRuleState + """ + super(ForwardingRule, self).__init__(**kwargs) + self.etag = None + self.system_data = None + self.domain_name = domain_name + self.target_dns_servers = target_dns_servers + self.metadata = metadata + self.forwarding_rule_state = forwarding_rule_state + self.provisioning_state = None + + +class ForwardingRuleListResult(msrest.serialization.Model): + """The response to an enumeration operation on forwarding rules within a DNS forwarding ruleset. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the forwarding rules. + :vartype value: list[~dns_resolver_management_client.models.ForwardingRule] + :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': '[ForwardingRule]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ForwardingRule"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the forwarding rules. + :paramtype value: list[~dns_resolver_management_client.models.ForwardingRule] + """ + super(ForwardingRuleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ForwardingRulePatch(msrest.serialization.Model): + """Describes a forwarding rule for PATCH operation. + + :ivar target_dns_servers: DNS servers to forward the DNS query to. + :vartype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :ivar metadata: Metadata attached to the forwarding rule. + :vartype metadata: dict[str, str] + :ivar forwarding_rule_state: The state of forwarding rule. Possible values include: "Enabled", + "Disabled". + :vartype forwarding_rule_state: str or + ~dns_resolver_management_client.models.ForwardingRuleState + """ + + _attribute_map = { + 'target_dns_servers': {'key': 'properties.targetDnsServers', 'type': '[TargetDnsServer]'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'forwarding_rule_state': {'key': 'properties.forwardingRuleState', 'type': 'str'}, + } + + def __init__( + self, + *, + target_dns_servers: Optional[List["TargetDnsServer"]] = None, + metadata: Optional[Dict[str, str]] = None, + forwarding_rule_state: Optional[Union[str, "ForwardingRuleState"]] = None, + **kwargs + ): + """ + :keyword target_dns_servers: DNS servers to forward the DNS query to. + :paramtype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :keyword metadata: Metadata attached to the forwarding rule. + :paramtype metadata: dict[str, str] + :keyword forwarding_rule_state: The state of forwarding rule. Possible values include: + "Enabled", "Disabled". + :paramtype forwarding_rule_state: str or + ~dns_resolver_management_client.models.ForwardingRuleState + """ + super(ForwardingRulePatch, self).__init__(**kwargs) + self.target_dns_servers = target_dns_servers + self.metadata = metadata + self.forwarding_rule_state = forwarding_rule_state + + +class InboundEndpoint(TrackedResource): + """Describes an inbound endpoint for a DNS resolver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :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: ~dns_resolver_management_client.models.SystemData + :ivar ip_configurations: IP configurations for the inbound endpoint. + :vartype ip_configurations: list[~dns_resolver_management_client.models.IpConfiguration] + :ivar provisioning_state: The current provisioning state of the inbound endpoint. This is a + read-only property and any attempt to set this value will be ignored. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :ivar resource_guid: The resourceGuid property of the inbound endpoint resource. + :vartype resource_guid: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'etag': {'readonly': True}, + 'system_data': {'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'}, + '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'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + ip_configurations: Optional[List["IpConfiguration"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword ip_configurations: IP configurations for the inbound endpoint. + :paramtype ip_configurations: list[~dns_resolver_management_client.models.IpConfiguration] + """ + super(InboundEndpoint, self).__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 + + +class InboundEndpointListResult(msrest.serialization.Model): + """The response to an enumeration operation on inbound endpoints for a DNS resolver. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the inbound endpoints for a DNS resolver. + :vartype value: list[~dns_resolver_management_client.models.InboundEndpoint] + :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': '[InboundEndpoint]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["InboundEndpoint"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the inbound endpoints for a DNS resolver. + :paramtype value: list[~dns_resolver_management_client.models.InboundEndpoint] + """ + super(InboundEndpointListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class InboundEndpointPatch(msrest.serialization.Model): + """Describes an inbound endpoint for a DNS resolver for PATCH operation. + + :ivar tags: A set of tags. Tags for inbound endpoint. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags for inbound endpoint. + :paramtype tags: dict[str, str] + """ + super(InboundEndpointPatch, self).__init__(**kwargs) + self.tags = tags + + +class IpConfiguration(msrest.serialization.Model): + """IP configuration. + + :ivar subnet: The reference to the subnet bound to the IP configuration. + :vartype subnet: ~dns_resolver_management_client.models.SubResource + :ivar private_ip_address: Private IP address of the IP configuration. + :vartype private_ip_address: str + :ivar private_ip_allocation_method: Private IP address allocation method. Possible values + include: "Static", "Dynamic". Default value: "Dynamic". + :vartype private_ip_allocation_method: str or + ~dns_resolver_management_client.models.IpAllocationMethod + """ + + _attribute_map = { + 'subnet': {'key': 'subnet', 'type': 'SubResource'}, + 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, + 'private_ip_allocation_method': {'key': 'privateIpAllocationMethod', 'type': 'str'}, + } + + def __init__( + self, + *, + subnet: Optional["SubResource"] = None, + private_ip_address: Optional[str] = None, + private_ip_allocation_method: Optional[Union[str, "IpAllocationMethod"]] = "Dynamic", + **kwargs + ): + """ + :keyword subnet: The reference to the subnet bound to the IP configuration. + :paramtype subnet: ~dns_resolver_management_client.models.SubResource + :keyword private_ip_address: Private IP address of the IP configuration. + :paramtype private_ip_address: str + :keyword private_ip_allocation_method: Private IP address allocation method. Possible values + include: "Static", "Dynamic". Default value: "Dynamic". + :paramtype private_ip_allocation_method: str or + ~dns_resolver_management_client.models.IpAllocationMethod + """ + super(IpConfiguration, self).__init__(**kwargs) + self.subnet = subnet + self.private_ip_address = private_ip_address + self.private_ip_allocation_method = private_ip_allocation_method + + +class OutboundEndpoint(TrackedResource): + """Describes an outbound endpoint for a DNS resolver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :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: ~dns_resolver_management_client.models.SystemData + :ivar subnet: The reference to the subnet used for the outbound endpoint. + :vartype subnet: ~dns_resolver_management_client.models.SubResource + :ivar provisioning_state: The current provisioning state of the outbound endpoint. This is a + read-only property and any attempt to set this value will be ignored. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :ivar resource_guid: The resourceGuid property of the outbound endpoint resource. + :vartype resource_guid: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'etag': {'readonly': True}, + 'system_data': {'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'}, + '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, + tags: Optional[Dict[str, str]] = None, + subnet: Optional["SubResource"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword subnet: The reference to the subnet used for the outbound endpoint. + :paramtype subnet: ~dns_resolver_management_client.models.SubResource + """ + super(OutboundEndpoint, self).__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.system_data = None + self.subnet = subnet + self.provisioning_state = None + self.resource_guid = None + + +class OutboundEndpointListResult(msrest.serialization.Model): + """The response to an enumeration operation on outbound endpoints for a DNS resolver. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the outbound endpoints for a DNS resolver. + :vartype value: list[~dns_resolver_management_client.models.OutboundEndpoint] + :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': '[OutboundEndpoint]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OutboundEndpoint"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the outbound endpoints for a DNS resolver. + :paramtype value: list[~dns_resolver_management_client.models.OutboundEndpoint] + """ + super(OutboundEndpointListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class OutboundEndpointPatch(msrest.serialization.Model): + """Describes an outbound endpoint for a DNS resolver for PATCH operation. + + :ivar tags: A set of tags. Tags for outbound endpoint. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags for outbound endpoint. + :paramtype tags: dict[str, str] + """ + super(OutboundEndpointPatch, self).__init__(**kwargs) + self.tags = tags + + +class SubResource(msrest.serialization.Model): + """Reference to another ARM resource. + + :ivar id: Resource ID. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ + super(SubResource, self).__init__(**kwargs) + self.id = id + + +class SubResourceListResult(msrest.serialization.Model): + """The response to an enumeration operation on sub-resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the sub-resources. + :vartype value: list[~dns_resolver_management_client.models.SubResource] + :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': '[SubResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["SubResource"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the sub-resources. + :paramtype value: list[~dns_resolver_management_client.models.SubResource] + """ + super(SubResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TargetDnsServer(msrest.serialization.Model): + """Describes a server to forward the DNS queries to. + + :ivar ip_address: DNS server IP address. + :vartype ip_address: str + :ivar port: DNS server port. + :vartype port: int + """ + + _attribute_map = { + 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + 'port': {'key': 'port', 'type': 'int'}, + } + + def __init__( + self, + *, + ip_address: Optional[str] = None, + port: Optional[int] = 53, + **kwargs + ): + """ + :keyword ip_address: DNS server IP address. + :paramtype ip_address: str + :keyword port: DNS server port. + :paramtype port: int + """ + super(TargetDnsServer, self).__init__(**kwargs) + self.ip_address = ip_address + self.port = port + + +class VirtualNetworkDnsForwardingRuleset(msrest.serialization.Model): + """Reference to DNS forwarding ruleset and associated virtual network link. + + :ivar id: DNS Forwarding Ruleset Resource ID. + :vartype id: str + :ivar virtual_network_link: The reference to the virtual network link. + :vartype virtual_network_link: ~dns_resolver_management_client.models.SubResource + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'virtual_network_link': {'key': 'properties.virtualNetworkLink', 'type': 'SubResource'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + virtual_network_link: Optional["SubResource"] = None, + **kwargs + ): + """ + :keyword id: DNS Forwarding Ruleset Resource ID. + :paramtype id: str + :keyword virtual_network_link: The reference to the virtual network link. + :paramtype virtual_network_link: ~dns_resolver_management_client.models.SubResource + """ + super(VirtualNetworkDnsForwardingRuleset, self).__init__(**kwargs) + self.id = id + self.virtual_network_link = virtual_network_link + + +class VirtualNetworkDnsForwardingRulesetListResult(msrest.serialization.Model): + """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. + + :ivar value: Enumeration of the Virtual Network DNS Forwarding Ruleset. + :vartype value: list[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRuleset] + :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': '[VirtualNetworkDnsForwardingRuleset]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VirtualNetworkDnsForwardingRuleset"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the Virtual Network DNS Forwarding Ruleset. + :paramtype value: + list[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRuleset] + """ + super(VirtualNetworkDnsForwardingRulesetListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class VirtualNetworkLink(ProxyResource): + """Describes a virtual network link. + + 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}. + :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 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: ~dns_resolver_management_client.models.SystemData + :ivar virtual_network: The reference to the virtual network. This cannot be changed after + creation. + :vartype virtual_network: ~dns_resolver_management_client.models.SubResource + :ivar metadata: Metadata attached to the virtual network link. + :vartype metadata: dict[str, str] + :ivar provisioning_state: The current provisioning state of the virtual network link. This is a + read-only property and any attempt to set this value will be ignored. Possible values include: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'system_data': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + '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: Optional["SubResource"] = None, + metadata: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword virtual_network: The reference to the virtual network. This cannot be changed after + creation. + :paramtype virtual_network: ~dns_resolver_management_client.models.SubResource + :keyword metadata: Metadata attached to the virtual network link. + :paramtype metadata: dict[str, str] + """ + super(VirtualNetworkLink, self).__init__(**kwargs) + self.etag = None + self.system_data = None + self.virtual_network = virtual_network + self.metadata = metadata + self.provisioning_state = None + + +class VirtualNetworkLinkListResult(msrest.serialization.Model): + """The response to an enumeration operation on virtual network links. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Enumeration of the virtual network links. + :vartype value: list[~dns_resolver_management_client.models.VirtualNetworkLink] + :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': '[VirtualNetworkLink]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["VirtualNetworkLink"]] = None, + **kwargs + ): + """ + :keyword value: Enumeration of the virtual network links. + :paramtype value: list[~dns_resolver_management_client.models.VirtualNetworkLink] + """ + super(VirtualNetworkLinkListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class VirtualNetworkLinkPatch(msrest.serialization.Model): + """Describes a virtual network link for PATCH operation. + + :ivar metadata: Metadata attached to the virtual network link. + :vartype metadata: dict[str, str] + """ + + _attribute_map = { + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword metadata: Metadata attached to the virtual network link. + :paramtype metadata: dict[str, str] + """ + super(VirtualNetworkLinkPatch, self).__init__(**kwargs) + self.metadata = metadata 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 new file mode 100644 index 000000000000..6656675bef07 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_resolvers_operations import DnsResolversOperations +from ._inbound_endpoints_operations import InboundEndpointsOperations +from ._outbound_endpoints_operations import OutboundEndpointsOperations +from ._dns_forwarding_rulesets_operations import DnsForwardingRulesetsOperations +from ._forwarding_rules_operations import ForwardingRulesOperations +from ._virtual_network_links_operations import VirtualNetworkLinksOperations + +__all__ = [ + 'DnsResolversOperations', + 'InboundEndpointsOperations', + 'OutboundEndpointsOperations', + 'DnsForwardingRulesetsOperations', + 'ForwardingRulesOperations', + 'VirtualNetworkLinksOperations', +] 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 new file mode 100644 index 000000000000..a3a29c5c21f9 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py @@ -0,0 +1,981 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_virtual_network_request( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class DnsForwardingRulesetsOperations(object): + """DnsForwardingRulesetsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRuleset", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsForwardingRuleset"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsForwardingRuleset') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRuleset", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.DnsForwardingRuleset"]: + """Creates or updates a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.DnsForwardingRuleset + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DnsForwardingRuleset or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRulesetPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsForwardingRuleset"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsForwardingRulesetPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + parameters: "_models.DnsForwardingRulesetPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.DnsForwardingRuleset"]: + """Updates a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.DnsForwardingRulesetPatch + :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. + :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 DnsForwardingRuleset or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding + rules within the ruleset will be deleted. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + **kwargs: Any + ) -> "_models.DnsForwardingRuleset": + """Gets a DNS forwarding ruleset properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :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: ~dns_resolver_management_client.models.DnsForwardingRuleset + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DnsForwardingRulesetListResult"]: + """Lists DNS forwarding rulesets within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsForwardingRulesetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + + @distributed_trace + def list( + self, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DnsForwardingRulesetListResult"]: + """Lists DNS forwarding rulesets in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsForwardingRulesetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + + @distributed_trace + def list_by_virtual_network( + self, + resource_group_name: str, + virtual_network_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkDnsForwardingRulesetListResult"]: + """Lists DNS forwarding ruleset resource IDs attached to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. + :type virtual_network_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 VirtualNetworkDnsForwardingRulesetListResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRulesetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkDnsForwardingRulesetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=self.list_by_virtual_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkDnsForwardingRulesetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets'} # type: ignore 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 new file mode 100644 index 000000000000..cd7d2ca91626 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py @@ -0,0 +1,978 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_virtual_network_request( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class DnsResolversOperations(object): + """DnsResolversOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolver", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsResolver"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResolver') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolver", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.DnsResolver"]: + """Creates or updates a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.DnsResolver + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DnsResolver or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsResolver] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsResolver', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolverPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.DnsResolver"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResolverPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DnsResolver', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + parameters: "_models.DnsResolverPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.DnsResolver"]: + """Updates a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.DnsResolverPatch + :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. + :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 DnsResolver or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsResolver] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('DnsResolver', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_resolver_name: str, + **kwargs: Any + ) -> "_models.DnsResolver": + """Gets properties of a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :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: ~dns_resolver_management_client.models.DnsResolver + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DnsResolver', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DnsResolverListResult"]: + """Lists DNS resolvers within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsResolverListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + + @distributed_trace + def list( + self, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DnsResolverListResult"]: + """Lists DNS resolvers in all resource groups of a subscription. + + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 DnsResolverListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DnsResolverListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + + @distributed_trace + def list_by_virtual_network( + self, + resource_group_name: str, + virtual_network_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SubResourceListResult"]: + """Lists DNS resolver resource IDs linked to a virtual network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param virtual_network_name: The name of the virtual network. + :type virtual_network_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 SubResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.SubResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=self.list_by_virtual_network.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_virtual_network_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SubResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers'} # type: ignore 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 new file mode 100644 index 000000000000..99badcbf9bf6 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py @@ -0,0 +1,608 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class ForwardingRulesOperations(object): + """ForwardingRulesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + parameters: "_models.ForwardingRule", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Creates or updates a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_rule_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.ForwardingRule + :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. + :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. + :type if_none_match: 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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForwardingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + parameters: "_models.ForwardingRulePatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Updates a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_rule_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.ForwardingRulePatch + :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. + :type if_match: 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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForwardingRulePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be + undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :type forwarding_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. + :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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + forwarding_rule_name: str, + **kwargs: Any + ) -> "_models.ForwardingRule": + """Gets properties of a forwarding rule in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param forwarding_rule_name: The name of the forwarding rule. + :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: ~dns_resolver_management_client.models.ForwardingRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + forwarding_rule_name=forwarding_rule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ForwardingRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ForwardingRuleListResult"]: + """Lists forwarding rules in a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 ForwardingRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.ForwardingRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ForwardingRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules'} # type: ignore 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 new file mode 100644 index 000000000000..089454583f18 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py @@ -0,0 +1,789 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class InboundEndpointsOperations(object): + """InboundEndpointsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.InboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InboundEndpoint') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.InboundEndpoint"]: + """Creates or updates an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.InboundEndpoint + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either InboundEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.InboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InboundEndpointPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + parameters: "_models.InboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.InboundEndpoint"]: + """Updates an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.InboundEndpointPatch + :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. + :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 InboundEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :type inbound_endpoint_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_resolver_name: str, + inbound_endpoint_name: str, + **kwargs: Any + ) -> "_models.InboundEndpoint": + """Gets properties of an inbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. + :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: ~dns_resolver_management_client.models.InboundEndpoint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + inbound_endpoint_name=inbound_endpoint_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_resolver_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.InboundEndpointListResult"]: + """Lists inbound endpoints for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 InboundEndpointListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.InboundEndpointListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpointListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("InboundEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints'} # type: ignore 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 new file mode 100644 index 000000000000..b5bc0e76e761 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py @@ -0,0 +1,789 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + dns_resolver_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class OutboundEndpointsOperations(object): + """OutboundEndpointsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.OutboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OutboundEndpoint') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpoint", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.OutboundEndpoint"]: + """Creates or updates an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.OutboundEndpoint + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OutboundEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.OutboundEndpoint"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OutboundEndpointPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + parameters: "_models.OutboundEndpointPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.OutboundEndpoint"]: + """Updates an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.OutboundEndpointPatch + :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. + :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 OutboundEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :type outbound_endpoint_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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_resolver_name: str, + outbound_endpoint_name: str, + **kwargs: Any + ) -> "_models.OutboundEndpoint": + """Gets properties of an outbound endpoint for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. + :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: ~dns_resolver_management_client.models.OutboundEndpoint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + outbound_endpoint_name=outbound_endpoint_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OutboundEndpoint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_resolver_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.OutboundEndpointListResult"]: + """Lists outbound endpoints for a DNS resolver. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_resolver_name: The name of the DNS resolver. + :type dns_resolver_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 OutboundEndpointListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.OutboundEndpointListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpointListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_resolver_name=dns_resolver_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OutboundEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints'} # type: ignore 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 new file mode 100644 index 000000000000..3354a7b1f9bf --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py @@ -0,0 +1,792 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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'), + "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class VirtualNetworkLinksOperations(object): + """VirtualNetworkLinksOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~dns_resolver_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLink", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.VirtualNetworkLink"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkLink') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + content_type=content_type, + json=_json, + if_match=if_match, + if_none_match=if_none_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLink", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualNetworkLink"]: + """Creates or updates a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type virtual_network_link_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLink + :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. + :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. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either VirtualNetworkLink or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLinkPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.VirtualNetworkLink"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkLinkPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + parameters: "_models.VirtualNetworkLinkPatch", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualNetworkLink"]: + """Updates a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type virtual_network_link_name: str + :param parameters: Parameters supplied to the Update operation. + :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLinkPatch + :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. + :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 VirtualNetworkLink or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + 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: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be + undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :type 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. + :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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + 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, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + virtual_network_link_name: str, + **kwargs: Any + ) -> "_models.VirtualNetworkLink": + """Gets properties of a virtual network link to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param virtual_network_link_name: The name of the virtual network link. + :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: ~dns_resolver_management_client.models.VirtualNetworkLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + virtual_network_link_name=virtual_network_link_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + dns_forwarding_ruleset_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkLinkListResult"]: + """Lists virtual network links to a DNS forwarding ruleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. + :type dns_forwarding_ruleset_name: str + :param top: The maximum number of results to return. If not specified, returns up to 100 + results. + :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 VirtualNetworkLinkListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.VirtualNetworkLinkListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLinkListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworkLinkListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks'} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/py.typed b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/sdk_packaging.toml b/sdk/dnsresolver/azure-mgmt-dnsresolver/sdk_packaging.toml new file mode 100644 index 000000000000..8c4a989658ed --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-dnsresolver" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py new file mode 100644 index 000000000000..58e6bddf6f91 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/setup.py @@ -0,0 +1,73 @@ +#!/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 +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-dnsresolver" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +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) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +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', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + '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', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/dnsresolver/ci.yml b/sdk/dnsresolver/ci.yml new file mode 100644 index 000000000000..c12e37e2c5c8 --- /dev/null +++ b/sdk/dnsresolver/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/dnsresolver/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/dnsresolver/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: dnsresolver + Artifacts: + - name: azure-mgmt-dnsresolver + safeName: azuremgmtdnsresolver