diff --git a/sdk/network/azure-mgmt-dns/_meta.json b/sdk/network/azure-mgmt-dns/_meta.json index 19cfa750a1e4..ea0f2695442b 100644 --- a/sdk/network/azure-mgmt-dns/_meta.json +++ b/sdk/network/azure-mgmt-dns/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.5", - "commit": "6fa6101166a28f1fd82d6a60b8038c9af236e2be", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "6b99a68f01d4ff7da9fcf5d6d315652ebc1d3031", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/dns/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.5 --version=3.3.0", + "autorest_command": "autorest specification/dns/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/dns/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py index d071d8cb9d78..d78a2da88693 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py index 018556c074ba..103549dd93d3 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_dns_management_client.py @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import DnsManagementClientConfiguration @@ -23,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +70,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DnsManagementClient, self).__init__( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py index 0a84eac865ac..6048236a549b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -64,4 +64,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py index a45870528b89..540d6ae1d453 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py @@ -11,16 +11,17 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import DnsManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +69,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DnsManagementClient, self).__init__( diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/__init__.py index a21e1fdf48bb..ae3cd3c5beba 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DnsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py index 4bbde6c0b319..e6ac3147b32e 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class DnsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py index 029bb1d755f7..ef2ca697315b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_dns_management_client.py @@ -6,25 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations from . import models +from ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -35,50 +33,58 @@ class DnsManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json index 851a947eeb48..b7405f95411b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "DnsManagementClient", "filename": "_dns_management_client", "description": "The DNS Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/__init__.py index 1a93fabcef86..8408ffb17ed9 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._dns_management_client import DnsManagementClient __all__ = ['DnsManagementClient'] + +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py index 819efcdcdc67..43417f9b01e5 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class DnsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py index bcad725200ac..69ae03921623 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py @@ -6,23 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations from .. import models +from ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -33,48 +33,58 @@ class DnsManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2016-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DnsManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/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/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py index 4fbf21039d25..606b244e5679 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._record_sets_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_dns_zone_request, build_list_by_type_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -49,7 +54,7 @@ async def update( record_type: Union[str, "_models.RecordType"], parameters: "_models.RecordSet", if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Updates a record set within a DNS zone. @@ -65,7 +70,7 @@ async def update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -77,37 +82,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,8 +120,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -131,7 +134,7 @@ async def create_or_update( parameters: "_models.RecordSet", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. @@ -148,10 +151,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -163,39 +166,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -212,16 +209,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. @@ -236,7 +236,7 @@ async def delete( :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -248,32 +248,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -283,15 +279,17 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Gets a record set. @@ -313,30 +311,27 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,8 +344,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, resource_group_name: str, @@ -358,7 +356,7 @@ def list_by_type( record_type: Union[str, "_models.RecordType"], top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. @@ -369,57 +367,60 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -428,7 +429,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,18 +442,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, resource_group_name: str, zone_name: str, top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. @@ -457,56 +464,58 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -515,7 +524,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,7 +537,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py index 7bdb708bee0c..7a0f92c3332b 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._zones_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +55,7 @@ async def create_or_update( parameters: "_models.Zone", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. @@ -62,10 +67,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -77,37 +82,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -124,44 +123,42 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + async def _delete_initial( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> Optional["_models.ZoneDeleteResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ZoneDeleteResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -176,14 +173,17 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ZoneDeleteResult"]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -194,17 +194,22 @@ async def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ZoneDeleteResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ZoneDeleteResult or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneDeleteResult"] lro_delay = kwargs.pop( @@ -217,27 +222,21 @@ async def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ZoneDeleteResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -247,15 +246,16 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. @@ -273,28 +273,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +304,66 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones 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 record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -371,7 +372,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -380,61 +385,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,7 +450,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,7 +463,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/__init__.py index 4f52b8ef8668..79b2e35e23a2 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/__init__.py @@ -6,46 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARecord - from ._models_py3 import AaaaRecord - from ._models_py3 import CloudErrorBody - from ._models_py3 import CnameRecord - from ._models_py3 import MxRecord - from ._models_py3 import NsRecord - from ._models_py3 import PtrRecord - from ._models_py3 import RecordSet - from ._models_py3 import RecordSetListResult - from ._models_py3 import RecordSetUpdateParameters - from ._models_py3 import Resource - from ._models_py3 import SoaRecord - from ._models_py3 import SrvRecord - from ._models_py3 import SubResource - from ._models_py3 import TrackedResource - from ._models_py3 import TxtRecord - from ._models_py3 import Zone - from ._models_py3 import ZoneDeleteResult - from ._models_py3 import ZoneListResult -except (SyntaxError, ImportError): - from ._models import ARecord # type: ignore - from ._models import AaaaRecord # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CnameRecord # type: ignore - from ._models import MxRecord # type: ignore - from ._models import NsRecord # type: ignore - from ._models import PtrRecord # type: ignore - from ._models import RecordSet # type: ignore - from ._models import RecordSetListResult # type: ignore - from ._models import RecordSetUpdateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import SoaRecord # type: ignore - from ._models import SrvRecord # type: ignore - from ._models import SubResource # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import TxtRecord # type: ignore - from ._models import Zone # type: ignore - from ._models import ZoneDeleteResult # type: ignore - from ._models import ZoneListResult # type: ignore +from ._models_py3 import ARecord +from ._models_py3 import AaaaRecord +from ._models_py3 import CloudErrorBody +from ._models_py3 import CnameRecord +from ._models_py3 import MxRecord +from ._models_py3 import NsRecord +from ._models_py3 import PtrRecord +from ._models_py3 import RecordSet +from ._models_py3 import RecordSetListResult +from ._models_py3 import RecordSetUpdateParameters +from ._models_py3 import Resource +from ._models_py3 import SoaRecord +from ._models_py3 import SrvRecord +from ._models_py3 import SubResource +from ._models_py3 import TrackedResource +from ._models_py3 import TxtRecord +from ._models_py3 import Zone +from ._models_py3 import ZoneDeleteResult +from ._models_py3 import ZoneListResult + from ._dns_management_client_enums import ( HttpStatusCode, diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py index d3200a6666eb..a3a0e4e6cc69 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_dns_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CONTINUE_ENUM = "Continue" SWITCHING_PROTOCOLS = "SwitchingProtocols" @@ -76,13 +61,13 @@ class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GATEWAY_TIMEOUT = "GatewayTimeout" HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" -class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" -class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecordType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): A = "A" AAAA = "AAAA" @@ -94,7 +79,7 @@ class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SRV = "SRV" TXT = "TXT" -class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ZoneType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of this DNS zone (Public or Private). """ diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models.py deleted file mode 100644 index 31cf91caa65f..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models.py +++ /dev/null @@ -1,623 +0,0 @@ -# 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 msrest.serialization - - -class AaaaRecord(msrest.serialization.Model): - """An AAAA record. - - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str - """ - - _attribute_map = { - 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AaaaRecord, self).__init__(**kwargs) - self.ipv6_address = kwargs.get('ipv6_address', None) - - -class ARecord(msrest.serialization.Model): - """An A record. - - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str - """ - - _attribute_map = { - 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARecord, self).__init__(**kwargs) - self.ipv4_address = kwargs.get('ipv4_address', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2016_04_01.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, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class CnameRecord(msrest.serialization.Model): - """A CNAME record. - - :param cname: The canonical name for this CNAME record. - :type cname: str - """ - - _attribute_map = { - 'cname': {'key': 'cname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CnameRecord, self).__init__(**kwargs) - self.cname = kwargs.get('cname', None) - - -class MxRecord(msrest.serialization.Model): - """An MX record. - - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str - """ - - _attribute_map = { - 'preference': {'key': 'preference', 'type': 'int'}, - 'exchange': {'key': 'exchange', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MxRecord, self).__init__(**kwargs) - self.preference = kwargs.get('preference', None) - self.exchange = kwargs.get('exchange', None) - - -class NsRecord(msrest.serialization.Model): - """An NS record. - - :param nsdname: The name server name for this NS record. - :type nsdname: str - """ - - _attribute_map = { - 'nsdname': {'key': 'nsdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NsRecord, self).__init__(**kwargs) - self.nsdname = kwargs.get('nsdname', None) - - -class PtrRecord(msrest.serialization.Model): - """A PTR record. - - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str - """ - - _attribute_map = { - 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PtrRecord, self).__init__(**kwargs) - self.ptrdname = kwargs.get('ptrdname', None) - - -class RecordSet(msrest.serialization.Model): - """Describes a DNS record set (a collection of DNS records with the same name and type). - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: The ID of the record set. - :type id: str - :param name: The name of the record set. - :type name: str - :param type: The type of the record set. - :type type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long - :ivar fqdn: Fully qualified domain name of the record set. - :vartype fqdn: str - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2016_04_01.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2016_04_01.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2016_04_01.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2016_04_01.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2016_04_01.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2016_04_01.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2016_04_01.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2016_04_01.models.SoaRecord - """ - - _validation = { - 'fqdn': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'ttl': {'key': 'properties.TTL', 'type': 'long'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'a_records': {'key': 'properties.ARecords', 'type': '[ARecord]'}, - 'aaaa_records': {'key': 'properties.AAAARecords', 'type': '[AaaaRecord]'}, - 'mx_records': {'key': 'properties.MXRecords', 'type': '[MxRecord]'}, - 'ns_records': {'key': 'properties.NSRecords', 'type': '[NsRecord]'}, - 'ptr_records': {'key': 'properties.PTRRecords', 'type': '[PtrRecord]'}, - 'srv_records': {'key': 'properties.SRVRecords', 'type': '[SrvRecord]'}, - 'txt_records': {'key': 'properties.TXTRecords', 'type': '[TxtRecord]'}, - 'cname_record': {'key': 'properties.CNAMERecord', 'type': 'CnameRecord'}, - 'soa_record': {'key': 'properties.SOARecord', 'type': 'SoaRecord'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSet, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.etag = kwargs.get('etag', None) - self.metadata = kwargs.get('metadata', None) - self.ttl = kwargs.get('ttl', None) - self.fqdn = None - self.a_records = kwargs.get('a_records', None) - self.aaaa_records = kwargs.get('aaaa_records', None) - self.mx_records = kwargs.get('mx_records', None) - self.ns_records = kwargs.get('ns_records', None) - self.ptr_records = kwargs.get('ptr_records', None) - self.srv_records = kwargs.get('srv_records', None) - self.txt_records = kwargs.get('txt_records', None) - self.cname_record = kwargs.get('cname_record', None) - self.soa_record = kwargs.get('soa_record', None) - - -class RecordSetListResult(msrest.serialization.Model): - """The response to a record set List operation. - - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2016_04_01.models.RecordSet] - :param next_link: The continuation token for the next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecordSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RecordSetUpdateParameters(msrest.serialization.Model): - """Parameters supplied to update a record set. - - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet - """ - - _attribute_map = { - 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetUpdateParameters, self).__init__(**kwargs) - self.record_set = kwargs.get('record_set', None) - - -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 SoaRecord(msrest.serialization.Model): - """An SOA record. - - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to - determine the negative caching duration. - :type minimum_ttl: long - """ - - _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'serial_number': {'key': 'serialNumber', 'type': 'long'}, - 'refresh_time': {'key': 'refreshTime', 'type': 'long'}, - 'retry_time': {'key': 'retryTime', 'type': 'long'}, - 'expire_time': {'key': 'expireTime', 'type': 'long'}, - 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(SoaRecord, self).__init__(**kwargs) - self.host = kwargs.get('host', None) - self.email = kwargs.get('email', None) - self.serial_number = kwargs.get('serial_number', None) - self.refresh_time = kwargs.get('refresh_time', None) - self.retry_time = kwargs.get('retry_time', None) - self.expire_time = kwargs.get('expire_time', None) - self.minimum_ttl = kwargs.get('minimum_ttl', None) - - -class SrvRecord(msrest.serialization.Model): - """An SRV record. - - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str - """ - - _attribute_map = { - 'priority': {'key': 'priority', 'type': 'int'}, - 'weight': {'key': 'weight', 'type': 'int'}, - 'port': {'key': 'port', 'type': 'int'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SrvRecord, self).__init__(**kwargs) - self.priority = kwargs.get('priority', None) - self.weight = kwargs.get('weight', None) - self.port = kwargs.get('port', None) - self.target = kwargs.get('target', None) - - -class SubResource(msrest.serialization.Model): - """SubResource. - - :param id: Resource Id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = kwargs.get('id', 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type 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, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class TxtRecord(msrest.serialization.Model): - """A TXT record. - - :param value: The text value of this TXT record. - :type value: list[str] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TxtRecord, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Zone(TrackedResource): - """Describes a DNS zone. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The etag of the zone. - :type etag: str - :param max_number_of_record_sets: The maximum number of record sets that can be created in this - DNS zone. This is a read-only property and any attempt to set this value will be ignored. - :type max_number_of_record_sets: long - :ivar max_number_of_records_per_record_set: The maximum number of records per record set that - can be created in this DNS zone. This is a read-only property and any attempt to set this - value will be ignored. - :vartype max_number_of_records_per_record_set: long - :param number_of_record_sets: The current number of record sets in this DNS zone. This is a - read-only property and any attempt to set this value will be ignored. - :type number_of_record_sets: long - :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any - attempt to set this value will be ignored. - :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: - "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2016_04_01.models.ZoneType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'max_number_of_records_per_record_set': {'readonly': True}, - 'name_servers': {'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'}, - 'max_number_of_record_sets': {'key': 'properties.maxNumberOfRecordSets', 'type': 'long'}, - 'max_number_of_records_per_record_set': {'key': 'properties.maxNumberOfRecordsPerRecordSet', 'type': 'long'}, - 'number_of_record_sets': {'key': 'properties.numberOfRecordSets', 'type': 'long'}, - 'name_servers': {'key': 'properties.nameServers', 'type': '[str]'}, - 'zone_type': {'key': 'properties.zoneType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Zone, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.max_number_of_record_sets = kwargs.get('max_number_of_record_sets', None) - self.max_number_of_records_per_record_set = None - self.number_of_record_sets = kwargs.get('number_of_record_sets', None) - self.name_servers = None - self.zone_type = kwargs.get('zone_type', "Public") - - -class ZoneDeleteResult(msrest.serialization.Model): - """The response to a Zone Delete operation. - - :param azure_async_operation: Users can perform a Get on Azure-AsyncOperation to get the status - of their delete Zone operations. - :type azure_async_operation: str - :param status: Possible values include: "InProgress", "Succeeded", "Failed". - :type status: str or ~azure.mgmt.dns.v2016_04_01.models.OperationStatus - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode - :param request_id: - :type request_id: str - """ - - _attribute_map = { - 'azure_async_operation': {'key': 'azureAsyncOperation', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneDeleteResult, self).__init__(**kwargs) - self.azure_async_operation = kwargs.get('azure_async_operation', None) - self.status = kwargs.get('status', None) - self.status_code = kwargs.get('status_code', None) - self.request_id = kwargs.get('request_id', None) - - -class ZoneListResult(msrest.serialization.Model): - """The response to a Zone List or ListAll operation. - - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2016_04_01.models.Zone] - :param next_link: The continuation token for the next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Zone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py index 8a2078aacd66..557bc296870e 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_models_py3.py @@ -16,8 +16,8 @@ class AaaaRecord(msrest.serialization.Model): """An AAAA record. - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str + :ivar ipv6_address: The IPv6 address of this AAAA record. + :vartype ipv6_address: str """ _attribute_map = { @@ -30,6 +30,10 @@ def __init__( ipv6_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv6_address: The IPv6 address of this AAAA record. + :paramtype ipv6_address: str + """ super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address @@ -37,8 +41,8 @@ def __init__( class ARecord(msrest.serialization.Model): """An A record. - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str + :ivar ipv4_address: The IPv4 address of this A record. + :vartype ipv4_address: str """ _attribute_map = { @@ -51,6 +55,10 @@ def __init__( ipv4_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv4_address: The IPv4 address of this A record. + :paramtype ipv4_address: str + """ super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address @@ -58,17 +66,17 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody] """ _attribute_map = { @@ -87,6 +95,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -97,8 +118,8 @@ def __init__( class CnameRecord(msrest.serialization.Model): """A CNAME record. - :param cname: The canonical name for this CNAME record. - :type cname: str + :ivar cname: The canonical name for this CNAME record. + :vartype cname: str """ _attribute_map = { @@ -111,6 +132,10 @@ def __init__( cname: Optional[str] = None, **kwargs ): + """ + :keyword cname: The canonical name for this CNAME record. + :paramtype cname: str + """ super(CnameRecord, self).__init__(**kwargs) self.cname = cname @@ -118,10 +143,10 @@ def __init__( class MxRecord(msrest.serialization.Model): """An MX record. - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str + :ivar preference: The preference value for this MX record. + :vartype preference: int + :ivar exchange: The domain name of the mail host for this MX record. + :vartype exchange: str """ _attribute_map = { @@ -136,6 +161,12 @@ def __init__( exchange: Optional[str] = None, **kwargs ): + """ + :keyword preference: The preference value for this MX record. + :paramtype preference: int + :keyword exchange: The domain name of the mail host for this MX record. + :paramtype exchange: str + """ super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange @@ -144,8 +175,8 @@ def __init__( class NsRecord(msrest.serialization.Model): """An NS record. - :param nsdname: The name server name for this NS record. - :type nsdname: str + :ivar nsdname: The name server name for this NS record. + :vartype nsdname: str """ _attribute_map = { @@ -158,6 +189,10 @@ def __init__( nsdname: Optional[str] = None, **kwargs ): + """ + :keyword nsdname: The name server name for this NS record. + :paramtype nsdname: str + """ super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname @@ -165,8 +200,8 @@ def __init__( class PtrRecord(msrest.serialization.Model): """A PTR record. - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str + :ivar ptrdname: The PTR target domain name for this PTR record. + :vartype ptrdname: str """ _attribute_map = { @@ -179,6 +214,10 @@ def __init__( ptrdname: Optional[str] = None, **kwargs ): + """ + :keyword ptrdname: The PTR target domain name for this PTR record. + :paramtype ptrdname: str + """ super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname @@ -188,38 +227,38 @@ class RecordSet(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: The ID of the record set. - :type id: str - :param name: The name of the record set. - :type name: str - :param type: The type of the record set. - :type type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long + :ivar id: The ID of the record set. + :vartype id: str + :ivar name: The name of the record set. + :vartype name: str + :ivar type: The type of the record set. + :vartype type: str + :ivar etag: The etag of the record set. + :vartype etag: str + :ivar metadata: The metadata attached to the record set. + :vartype metadata: dict[str, str] + :ivar ttl: The TTL (time-to-live) of the records in the record set. + :vartype ttl: long :ivar fqdn: Fully qualified domain name of the record set. :vartype fqdn: str - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2016_04_01.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2016_04_01.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2016_04_01.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2016_04_01.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2016_04_01.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2016_04_01.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2016_04_01.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2016_04_01.models.SoaRecord + :ivar a_records: The list of A records in the record set. + :vartype a_records: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] + :ivar aaaa_records: The list of AAAA records in the record set. + :vartype aaaa_records: list[~azure.mgmt.dns.v2016_04_01.models.AaaaRecord] + :ivar mx_records: The list of MX records in the record set. + :vartype mx_records: list[~azure.mgmt.dns.v2016_04_01.models.MxRecord] + :ivar ns_records: The list of NS records in the record set. + :vartype ns_records: list[~azure.mgmt.dns.v2016_04_01.models.NsRecord] + :ivar ptr_records: The list of PTR records in the record set. + :vartype ptr_records: list[~azure.mgmt.dns.v2016_04_01.models.PtrRecord] + :ivar srv_records: The list of SRV records in the record set. + :vartype srv_records: list[~azure.mgmt.dns.v2016_04_01.models.SrvRecord] + :ivar txt_records: The list of TXT records in the record set. + :vartype txt_records: list[~azure.mgmt.dns.v2016_04_01.models.TxtRecord] + :ivar cname_record: The CNAME record in the record set. + :vartype cname_record: ~azure.mgmt.dns.v2016_04_01.models.CnameRecord + :ivar soa_record: The SOA record in the record set. + :vartype soa_record: ~azure.mgmt.dns.v2016_04_01.models.SoaRecord """ _validation = { @@ -265,6 +304,38 @@ def __init__( soa_record: Optional["SoaRecord"] = None, **kwargs ): + """ + :keyword id: The ID of the record set. + :paramtype id: str + :keyword name: The name of the record set. + :paramtype name: str + :keyword type: The type of the record set. + :paramtype type: str + :keyword etag: The etag of the record set. + :paramtype etag: str + :keyword metadata: The metadata attached to the record set. + :paramtype metadata: dict[str, str] + :keyword ttl: The TTL (time-to-live) of the records in the record set. + :paramtype ttl: long + :keyword a_records: The list of A records in the record set. + :paramtype a_records: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] + :keyword aaaa_records: The list of AAAA records in the record set. + :paramtype aaaa_records: list[~azure.mgmt.dns.v2016_04_01.models.AaaaRecord] + :keyword mx_records: The list of MX records in the record set. + :paramtype mx_records: list[~azure.mgmt.dns.v2016_04_01.models.MxRecord] + :keyword ns_records: The list of NS records in the record set. + :paramtype ns_records: list[~azure.mgmt.dns.v2016_04_01.models.NsRecord] + :keyword ptr_records: The list of PTR records in the record set. + :paramtype ptr_records: list[~azure.mgmt.dns.v2016_04_01.models.PtrRecord] + :keyword srv_records: The list of SRV records in the record set. + :paramtype srv_records: list[~azure.mgmt.dns.v2016_04_01.models.SrvRecord] + :keyword txt_records: The list of TXT records in the record set. + :paramtype txt_records: list[~azure.mgmt.dns.v2016_04_01.models.TxtRecord] + :keyword cname_record: The CNAME record in the record set. + :paramtype cname_record: ~azure.mgmt.dns.v2016_04_01.models.CnameRecord + :keyword soa_record: The SOA record in the record set. + :paramtype soa_record: ~azure.mgmt.dns.v2016_04_01.models.SoaRecord + """ super(RecordSet, self).__init__(**kwargs) self.id = id self.name = name @@ -287,10 +358,10 @@ def __init__( class RecordSetListResult(msrest.serialization.Model): """The response to a record set List operation. - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2016_04_01.models.RecordSet] - :param next_link: The continuation token for the next page of results. - :type next_link: str + :ivar value: Information about the record sets in the response. + :vartype value: list[~azure.mgmt.dns.v2016_04_01.models.RecordSet] + :ivar next_link: The continuation token for the next page of results. + :vartype next_link: str """ _attribute_map = { @@ -305,6 +376,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Information about the record sets in the response. + :paramtype value: list[~azure.mgmt.dns.v2016_04_01.models.RecordSet] + :keyword next_link: The continuation token for the next page of results. + :paramtype next_link: str + """ super(RecordSetListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -313,8 +390,8 @@ def __init__( class RecordSetUpdateParameters(msrest.serialization.Model): """Parameters supplied to update a record set. - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :ivar record_set: Specifies information about the record set being updated. + :vartype record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet """ _attribute_map = { @@ -327,6 +404,10 @@ def __init__( record_set: Optional["RecordSet"] = None, **kwargs ): + """ + :keyword record_set: Specifies information about the record set being updated. + :paramtype record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + """ super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set @@ -362,6 +443,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -371,21 +454,21 @@ def __init__( class SoaRecord(msrest.serialization.Model): """An SOA record. - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to + :ivar host: The domain name of the authoritative name server for this SOA record. + :vartype host: str + :ivar email: The email contact for this SOA record. + :vartype email: str + :ivar serial_number: The serial number for this SOA record. + :vartype serial_number: long + :ivar refresh_time: The refresh value for this SOA record. + :vartype refresh_time: long + :ivar retry_time: The retry time for this SOA record. + :vartype retry_time: long + :ivar expire_time: The expire time for this SOA record. + :vartype expire_time: long + :ivar minimum_ttl: The minimum value for this SOA record. By convention this is used to determine the negative caching duration. - :type minimum_ttl: long + :vartype minimum_ttl: long """ _attribute_map = { @@ -410,6 +493,23 @@ def __init__( minimum_ttl: Optional[int] = None, **kwargs ): + """ + :keyword host: The domain name of the authoritative name server for this SOA record. + :paramtype host: str + :keyword email: The email contact for this SOA record. + :paramtype email: str + :keyword serial_number: The serial number for this SOA record. + :paramtype serial_number: long + :keyword refresh_time: The refresh value for this SOA record. + :paramtype refresh_time: long + :keyword retry_time: The retry time for this SOA record. + :paramtype retry_time: long + :keyword expire_time: The expire time for this SOA record. + :paramtype expire_time: long + :keyword minimum_ttl: The minimum value for this SOA record. By convention this is used to + determine the negative caching duration. + :paramtype minimum_ttl: long + """ super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -423,14 +523,14 @@ def __init__( class SrvRecord(msrest.serialization.Model): """An SRV record. - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str + :ivar priority: The priority value for this SRV record. + :vartype priority: int + :ivar weight: The weight value for this SRV record. + :vartype weight: int + :ivar port: The port value for this SRV record. + :vartype port: int + :ivar target: The target domain name for this SRV record. + :vartype target: str """ _attribute_map = { @@ -449,6 +549,16 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword priority: The priority value for this SRV record. + :paramtype priority: int + :keyword weight: The weight value for this SRV record. + :paramtype weight: int + :keyword port: The port value for this SRV record. + :paramtype port: int + :keyword target: The target domain name for this SRV record. + :paramtype target: str + """ super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -459,8 +569,8 @@ def __init__( class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -473,6 +583,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -492,10 +606,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: 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 = { @@ -520,6 +634,12 @@ def __init__( 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 @@ -528,8 +648,8 @@ def __init__( class TxtRecord(msrest.serialization.Model): """A TXT record. - :param value: The text value of this TXT record. - :type value: list[str] + :ivar value: The text value of this TXT record. + :vartype value: list[str] """ _attribute_map = { @@ -542,6 +662,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The text value of this TXT record. + :paramtype value: list[str] + """ super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -561,28 +685,28 @@ class Zone(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The etag of the zone. - :type etag: str - :param max_number_of_record_sets: The maximum number of record sets that can be created in this + :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: The etag of the zone. + :vartype etag: str + :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - :type max_number_of_record_sets: long + :vartype max_number_of_record_sets: long :ivar max_number_of_records_per_record_set: The maximum number of records per record set that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype max_number_of_records_per_record_set: long - :param number_of_record_sets: The current number of record sets in this DNS zone. This is a + :ivar number_of_record_sets: The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. - :type number_of_record_sets: long + :vartype number_of_record_sets: long :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: + :ivar zone_type: The type of this DNS zone (Public or Private). Possible values include: "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2016_04_01.models.ZoneType + :vartype zone_type: str or ~azure.mgmt.dns.v2016_04_01.models.ZoneType """ _validation = { @@ -619,6 +743,23 @@ def __init__( zone_type: Optional[Union[str, "ZoneType"]] = "Public", **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 etag: The etag of the zone. + :paramtype etag: str + :keyword max_number_of_record_sets: The maximum number of record sets that can be created in + this DNS zone. This is a read-only property and any attempt to set this value will be ignored. + :paramtype max_number_of_record_sets: long + :keyword number_of_record_sets: The current number of record sets in this DNS zone. This is a + read-only property and any attempt to set this value will be ignored. + :paramtype number_of_record_sets: long + :keyword zone_type: The type of this DNS zone (Public or Private). Possible values include: + "Public", "Private". Default value: "Public". + :paramtype zone_type: str or ~azure.mgmt.dns.v2016_04_01.models.ZoneType + """ super(Zone, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.max_number_of_record_sets = max_number_of_record_sets @@ -631,25 +772,24 @@ def __init__( class ZoneDeleteResult(msrest.serialization.Model): """The response to a Zone Delete operation. - :param azure_async_operation: Users can perform a Get on Azure-AsyncOperation to get the status + :ivar azure_async_operation: Users can perform a Get on Azure-AsyncOperation to get the status of their delete Zone operations. - :type azure_async_operation: str - :param status: Possible values include: "InProgress", "Succeeded", "Failed". - :type status: str or ~azure.mgmt.dns.v2016_04_01.models.OperationStatus - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + :vartype azure_async_operation: str + :ivar status: Possible values include: "InProgress", "Succeeded", "Failed". + :vartype status: str or ~azure.mgmt.dns.v2016_04_01.models.OperationStatus + :ivar status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", "Created", + "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", + "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", "Redirect", "SeeOther", + "RedirectMethod", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "RedirectKeepVerb", + "BadRequest", "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", + "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", + "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", + "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", + "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode - :param request_id: - :type request_id: str + :vartype status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode + :ivar request_id: + :vartype request_id: str """ _attribute_map = { @@ -668,6 +808,27 @@ def __init__( request_id: Optional[str] = None, **kwargs ): + """ + :keyword azure_async_operation: Users can perform a Get on Azure-AsyncOperation to get the + status of their delete Zone operations. + :paramtype azure_async_operation: str + :keyword status: Possible values include: "InProgress", "Succeeded", "Failed". + :paramtype status: str or ~azure.mgmt.dns.v2016_04_01.models.OperationStatus + :keyword status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", + "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", + "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", + "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", + "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", + "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", + "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", + "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", + "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", + "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + "HttpVersionNotSupported". + :paramtype status_code: str or ~azure.mgmt.dns.v2016_04_01.models.HttpStatusCode + :keyword request_id: + :paramtype request_id: str + """ super(ZoneDeleteResult, self).__init__(**kwargs) self.azure_async_operation = azure_async_operation self.status = status @@ -678,10 +839,10 @@ def __init__( class ZoneListResult(msrest.serialization.Model): """The response to a Zone List or ListAll operation. - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2016_04_01.models.Zone] - :param next_link: The continuation token for the next page of results. - :type next_link: str + :ivar value: Information about the DNS zones. + :vartype value: list[~azure.mgmt.dns.v2016_04_01.models.Zone] + :ivar next_link: The continuation token for the next page of results. + :vartype next_link: str """ _attribute_map = { @@ -696,6 +857,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Information about the DNS zones. + :paramtype value: list[~azure.mgmt.dns.v2016_04_01.models.Zone] + :keyword next_link: The continuation token for the next page of results. + :paramtype next_link: str + """ super(ZoneListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py index 932e496155e1..760ecefb96da 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,302 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_create_or_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_delete_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_type_request( + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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 + ) class RecordSetsOperations(object): """RecordSetsOperations operations. @@ -45,17 +325,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,7 +350,7 @@ def update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -82,37 +362,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,20 +400,22 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -154,10 +431,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -169,39 +446,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,18 +489,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -243,7 +516,7 @@ def delete( :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -255,32 +528,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -290,17 +559,18 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs: Any + ) -> "_models.RecordSet": """Gets a record set. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -321,30 +591,27 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,18 +624,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, - resource_group_name, # type: str - zone_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -378,57 +647,59 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,7 +708,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,20 +721,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, - resource_group_name, # type: str - zone_name, # type: str - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -467,56 +743,57 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,7 +802,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -534,7 +815,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py index c7a184a37bdc..1d9eca2d3833 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,227 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_delete_request_initial( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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( + resource_group_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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 + ) class ZonesOperations(object): """ZonesOperations operations. @@ -47,16 +250,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - parameters, # type: "_models.Zone" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,10 +270,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2016_04_01.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -82,37 +285,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -129,45 +326,42 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ZoneDeleteResult"] + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.ZoneDeleteResult"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ZoneDeleteResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -182,16 +376,18 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ZoneDeleteResult"] + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.ZoneDeleteResult"]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -201,17 +397,22 @@ def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ZoneDeleteResult or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ZoneDeleteResult or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneDeleteResult"] lro_delay = kwargs.pop( @@ -224,27 +425,21 @@ def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ZoneDeleteResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -254,17 +449,17 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + **kwargs: Any + ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -281,28 +476,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2016-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,63 +507,65 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones 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 record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -380,7 +574,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,62 +587,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2016_04_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2016-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,7 +651,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -462,7 +664,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/__init__.py index a21e1fdf48bb..ae3cd3c5beba 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DnsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py index cb498028e61d..6be9aa373792 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class DnsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py index efccda800ec4..ead82545a324 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_dns_management_client.py @@ -6,25 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations from . import models +from ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -35,50 +33,58 @@ class DnsManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json index 688974d9598e..f3b6922fa2b2 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "DnsManagementClient", "filename": "_dns_management_client", "description": "The DNS Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/__init__.py index 1a93fabcef86..8408ffb17ed9 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._dns_management_client import DnsManagementClient __all__ = ['DnsManagementClient'] + +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py index b16605df59f1..854af663a4cc 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class DnsManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py index acf324682771..9f6eef6737c4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py @@ -6,23 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations from .. import models +from ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -33,48 +33,58 @@ class DnsManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DnsManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py index bccc0caaa891..137cbf81f416 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._record_sets_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_all_by_dns_zone_request, build_list_by_dns_zone_request, build_list_by_type_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -49,7 +54,7 @@ async def update( record_type: Union[str, "_models.RecordType"], parameters: "_models.RecordSet", if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Updates a record set within a DNS zone. @@ -65,7 +70,7 @@ async def update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -77,37 +82,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,8 +120,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -131,7 +134,7 @@ async def create_or_update( parameters: "_models.RecordSet", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. @@ -148,10 +151,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -163,39 +166,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -212,16 +209,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. @@ -236,7 +236,7 @@ async def delete( :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -248,32 +248,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -283,15 +279,17 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Gets a record set. @@ -313,30 +311,27 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,8 +344,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, resource_group_name: str, @@ -358,7 +356,7 @@ def list_by_type( record_type: Union[str, "_models.RecordType"], top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. @@ -369,57 +367,60 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -428,7 +429,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,18 +442,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, resource_group_name: str, zone_name: str, top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. @@ -457,56 +464,58 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -515,7 +524,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,18 +537,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore + @distributed_trace def list_all_by_dns_zone( self, resource_group_name: str, zone_name: str, top: Optional[int] = None, record_set_name_suffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. @@ -544,56 +559,58 @@ def list_all_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param record_set_name_suffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if record_set_name_suffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("record_set_name_suffix", record_set_name_suffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + template_url=self.list_all_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -602,7 +619,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -611,7 +632,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} # type: ignore + list_all_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py index 0a8e5e605719..fe4cdcf3ace3 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._zones_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +55,7 @@ async def create_or_update( parameters: "_models.Zone", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. @@ -62,10 +67,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -77,37 +82,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -124,44 +123,42 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore - async def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **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', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -171,14 +168,16 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -189,17 +188,21 @@ async def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -212,24 +215,18 @@ async def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -239,15 +236,16 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. @@ -265,28 +263,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -299,15 +294,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, zone_name: str, parameters: "_models.ZoneUpdate", if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Updates a DNS zone. Does not modify DNS records within the zone. @@ -319,7 +317,7 @@ async def update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -331,35 +329,30 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ZoneUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ZoneUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -372,62 +365,66 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones 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 record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,7 +433,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -445,61 +446,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -508,7 +511,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -517,7 +524,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/__init__.py index 3d5d2b3afee4..e1c1e6a9bab3 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/__init__.py @@ -6,48 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARecord - from ._models_py3 import AaaaRecord - from ._models_py3 import CaaRecord - from ._models_py3 import CloudErrorBody - from ._models_py3 import CnameRecord - from ._models_py3 import MxRecord - from ._models_py3 import NsRecord - from ._models_py3 import PtrRecord - from ._models_py3 import RecordSet - from ._models_py3 import RecordSetListResult - from ._models_py3 import RecordSetUpdateParameters - from ._models_py3 import Resource - from ._models_py3 import SoaRecord - from ._models_py3 import SrvRecord - from ._models_py3 import SubResource - from ._models_py3 import TrackedResource - from ._models_py3 import TxtRecord - from ._models_py3 import Zone - from ._models_py3 import ZoneListResult - from ._models_py3 import ZoneUpdate -except (SyntaxError, ImportError): - from ._models import ARecord # type: ignore - from ._models import AaaaRecord # type: ignore - from ._models import CaaRecord # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CnameRecord # type: ignore - from ._models import MxRecord # type: ignore - from ._models import NsRecord # type: ignore - from ._models import PtrRecord # type: ignore - from ._models import RecordSet # type: ignore - from ._models import RecordSetListResult # type: ignore - from ._models import RecordSetUpdateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import SoaRecord # type: ignore - from ._models import SrvRecord # type: ignore - from ._models import SubResource # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import TxtRecord # type: ignore - from ._models import Zone # type: ignore - from ._models import ZoneListResult # type: ignore - from ._models import ZoneUpdate # type: ignore +from ._models_py3 import ARecord +from ._models_py3 import AaaaRecord +from ._models_py3 import CaaRecord +from ._models_py3 import CloudErrorBody +from ._models_py3 import CnameRecord +from ._models_py3 import MxRecord +from ._models_py3 import NsRecord +from ._models_py3 import PtrRecord +from ._models_py3 import RecordSet +from ._models_py3 import RecordSetListResult +from ._models_py3 import RecordSetUpdateParameters +from ._models_py3 import Resource +from ._models_py3 import SoaRecord +from ._models_py3 import SrvRecord +from ._models_py3 import SubResource +from ._models_py3 import TrackedResource +from ._models_py3 import TxtRecord +from ._models_py3 import Zone +from ._models_py3 import ZoneListResult +from ._models_py3 import ZoneUpdate + from ._dns_management_client_enums import ( RecordType, diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_dns_management_client_enums.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_dns_management_client_enums.py index f2abeece2155..b9c9308e013a 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_dns_management_client_enums.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_dns_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecordType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): A = "A" AAAA = "AAAA" @@ -39,7 +24,7 @@ class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SRV = "SRV" TXT = "TXT" -class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ZoneType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of this DNS zone (Public or Private). """ diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models.py deleted file mode 100644 index 11d7260189db..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models.py +++ /dev/null @@ -1,659 +0,0 @@ -# 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 msrest.serialization - - -class AaaaRecord(msrest.serialization.Model): - """An AAAA record. - - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str - """ - - _attribute_map = { - 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AaaaRecord, self).__init__(**kwargs) - self.ipv6_address = kwargs.get('ipv6_address', None) - - -class ARecord(msrest.serialization.Model): - """An A record. - - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str - """ - - _attribute_map = { - 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARecord, self).__init__(**kwargs) - self.ipv4_address = kwargs.get('ipv4_address', None) - - -class CaaRecord(msrest.serialization.Model): - """A CAA record. - - :param flags: The flags for this CAA record as an integer between 0 and 255. - :type flags: int - :param tag: The tag for this CAA record. - :type tag: str - :param value: The value for this CAA record. - :type value: str - """ - - _attribute_map = { - 'flags': {'key': 'flags', 'type': 'int'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CaaRecord, self).__init__(**kwargs) - self.flags = kwargs.get('flags', None) - self.tag = kwargs.get('tag', None) - self.value = kwargs.get('value', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class CnameRecord(msrest.serialization.Model): - """A CNAME record. - - :param cname: The canonical name for this CNAME record. - :type cname: str - """ - - _attribute_map = { - 'cname': {'key': 'cname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CnameRecord, self).__init__(**kwargs) - self.cname = kwargs.get('cname', None) - - -class MxRecord(msrest.serialization.Model): - """An MX record. - - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str - """ - - _attribute_map = { - 'preference': {'key': 'preference', 'type': 'int'}, - 'exchange': {'key': 'exchange', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MxRecord, self).__init__(**kwargs) - self.preference = kwargs.get('preference', None) - self.exchange = kwargs.get('exchange', None) - - -class NsRecord(msrest.serialization.Model): - """An NS record. - - :param nsdname: The name server name for this NS record. - :type nsdname: str - """ - - _attribute_map = { - 'nsdname': {'key': 'nsdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NsRecord, self).__init__(**kwargs) - self.nsdname = kwargs.get('nsdname', None) - - -class PtrRecord(msrest.serialization.Model): - """A PTR record. - - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str - """ - - _attribute_map = { - 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PtrRecord, self).__init__(**kwargs) - self.ptrdname = kwargs.get('ptrdname', None) - - -class RecordSet(msrest.serialization.Model): - """Describes a DNS record set (a collection of DNS records with the same name and type). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the record set. - :vartype id: str - :ivar name: The name of the record set. - :vartype name: str - :ivar type: The type of the record set. - :vartype type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long - :ivar fqdn: Fully qualified domain name of the record set. - :vartype fqdn: str - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2018_03_01_preview.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2018_03_01_preview.models.SoaRecord - :param caa_records: The list of CAA records in the record set. - :type caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'fqdn': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'ttl': {'key': 'properties.TTL', 'type': 'long'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'a_records': {'key': 'properties.ARecords', 'type': '[ARecord]'}, - 'aaaa_records': {'key': 'properties.AAAARecords', 'type': '[AaaaRecord]'}, - 'mx_records': {'key': 'properties.MXRecords', 'type': '[MxRecord]'}, - 'ns_records': {'key': 'properties.NSRecords', 'type': '[NsRecord]'}, - 'ptr_records': {'key': 'properties.PTRRecords', 'type': '[PtrRecord]'}, - 'srv_records': {'key': 'properties.SRVRecords', 'type': '[SrvRecord]'}, - 'txt_records': {'key': 'properties.TXTRecords', 'type': '[TxtRecord]'}, - 'cname_record': {'key': 'properties.CNAMERecord', 'type': 'CnameRecord'}, - 'soa_record': {'key': 'properties.SOARecord', 'type': 'SoaRecord'}, - 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSet, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = kwargs.get('etag', None) - self.metadata = kwargs.get('metadata', None) - self.ttl = kwargs.get('ttl', None) - self.fqdn = None - self.a_records = kwargs.get('a_records', None) - self.aaaa_records = kwargs.get('aaaa_records', None) - self.mx_records = kwargs.get('mx_records', None) - self.ns_records = kwargs.get('ns_records', None) - self.ptr_records = kwargs.get('ptr_records', None) - self.srv_records = kwargs.get('srv_records', None) - self.txt_records = kwargs.get('txt_records', None) - self.cname_record = kwargs.get('cname_record', None) - self.soa_record = kwargs.get('soa_record', None) - self.caa_records = kwargs.get('caa_records', None) - - -class RecordSetListResult(msrest.serialization.Model): - """The response to a record set List operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] - :ivar next_link: The continuation token for the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecordSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RecordSetUpdateParameters(msrest.serialization.Model): - """Parameters supplied to update a record set. - - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet - """ - - _attribute_map = { - 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetUpdateParameters, self).__init__(**kwargs) - self.record_set = kwargs.get('record_set', None) - - -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 SoaRecord(msrest.serialization.Model): - """An SOA record. - - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to - determine the negative caching duration. - :type minimum_ttl: long - """ - - _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'serial_number': {'key': 'serialNumber', 'type': 'long'}, - 'refresh_time': {'key': 'refreshTime', 'type': 'long'}, - 'retry_time': {'key': 'retryTime', 'type': 'long'}, - 'expire_time': {'key': 'expireTime', 'type': 'long'}, - 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(SoaRecord, self).__init__(**kwargs) - self.host = kwargs.get('host', None) - self.email = kwargs.get('email', None) - self.serial_number = kwargs.get('serial_number', None) - self.refresh_time = kwargs.get('refresh_time', None) - self.retry_time = kwargs.get('retry_time', None) - self.expire_time = kwargs.get('expire_time', None) - self.minimum_ttl = kwargs.get('minimum_ttl', None) - - -class SrvRecord(msrest.serialization.Model): - """An SRV record. - - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str - """ - - _attribute_map = { - 'priority': {'key': 'priority', 'type': 'int'}, - 'weight': {'key': 'weight', 'type': 'int'}, - 'port': {'key': 'port', 'type': 'int'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SrvRecord, self).__init__(**kwargs) - self.priority = kwargs.get('priority', None) - self.weight = kwargs.get('weight', None) - self.port = kwargs.get('port', None) - self.target = kwargs.get('target', None) - - -class SubResource(msrest.serialization.Model): - """A reference to a another resource. - - :param id: Resource Id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = kwargs.get('id', 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type 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, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class TxtRecord(msrest.serialization.Model): - """A TXT record. - - :param value: The text value of this TXT record. - :type value: list[str] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TxtRecord, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Zone(TrackedResource): - """Describes a DNS zone. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: 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 - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The etag of the zone. - :type etag: str - :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this - DNS zone. This is a read-only property and any attempt to set this value will be ignored. - :vartype max_number_of_record_sets: long - :ivar max_number_of_records_per_record_set: The maximum number of records per record set that - can be created in this DNS zone. This is a read-only property and any attempt to set this - value will be ignored. - :vartype max_number_of_records_per_record_set: long - :ivar number_of_record_sets: The current number of record sets in this DNS zone. This is a - read-only property and any attempt to set this value will be ignored. - :vartype number_of_record_sets: long - :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any - attempt to set this value will be ignored. - :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: - "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneType - :param registration_virtual_networks: A list of references to virtual networks that register - hostnames in this DNS zone. This is a only when ZoneType is Private. - :type registration_virtual_networks: - list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] - :param resolution_virtual_networks: A list of references to virtual networks that resolve - records in this DNS zone. This is a only when ZoneType is Private. - :type resolution_virtual_networks: list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'max_number_of_record_sets': {'readonly': True}, - 'max_number_of_records_per_record_set': {'readonly': True}, - 'number_of_record_sets': {'readonly': True}, - 'name_servers': {'readonly': True}, - } - - _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'}, - 'max_number_of_record_sets': {'key': 'properties.maxNumberOfRecordSets', 'type': 'long'}, - 'max_number_of_records_per_record_set': {'key': 'properties.maxNumberOfRecordsPerRecordSet', 'type': 'long'}, - 'number_of_record_sets': {'key': 'properties.numberOfRecordSets', 'type': 'long'}, - 'name_servers': {'key': 'properties.nameServers', 'type': '[str]'}, - 'zone_type': {'key': 'properties.zoneType', 'type': 'str'}, - 'registration_virtual_networks': {'key': 'properties.registrationVirtualNetworks', 'type': '[SubResource]'}, - 'resolution_virtual_networks': {'key': 'properties.resolutionVirtualNetworks', 'type': '[SubResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(Zone, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.max_number_of_record_sets = None - self.max_number_of_records_per_record_set = None - self.number_of_record_sets = None - self.name_servers = None - self.zone_type = kwargs.get('zone_type', "Public") - self.registration_virtual_networks = kwargs.get('registration_virtual_networks', None) - self.resolution_virtual_networks = kwargs.get('resolution_virtual_networks', None) - - -class ZoneListResult(msrest.serialization.Model): - """The response to a Zone List or ListAll operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] - :ivar next_link: The continuation token for the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Zone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ZoneUpdate(msrest.serialization.Model): - """Describes a request to update a DNS zone. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py index 8288d18b8b61..01a12fdbd775 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_models_py3.py @@ -16,8 +16,8 @@ class AaaaRecord(msrest.serialization.Model): """An AAAA record. - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str + :ivar ipv6_address: The IPv6 address of this AAAA record. + :vartype ipv6_address: str """ _attribute_map = { @@ -30,6 +30,10 @@ def __init__( ipv6_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv6_address: The IPv6 address of this AAAA record. + :paramtype ipv6_address: str + """ super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address @@ -37,8 +41,8 @@ def __init__( class ARecord(msrest.serialization.Model): """An A record. - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str + :ivar ipv4_address: The IPv4 address of this A record. + :vartype ipv4_address: str """ _attribute_map = { @@ -51,6 +55,10 @@ def __init__( ipv4_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv4_address: The IPv4 address of this A record. + :paramtype ipv4_address: str + """ super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address @@ -58,12 +66,12 @@ def __init__( class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and 255. - :type flags: int - :param tag: The tag for this CAA record. - :type tag: str - :param value: The value for this CAA record. - :type value: str + :ivar flags: The flags for this CAA record as an integer between 0 and 255. + :vartype flags: int + :ivar tag: The tag for this CAA record. + :vartype tag: str + :ivar value: The value for this CAA record. + :vartype value: str """ _attribute_map = { @@ -80,6 +88,14 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword flags: The flags for this CAA record as an integer between 0 and 255. + :paramtype flags: int + :keyword tag: The tag for this CAA record. + :paramtype tag: str + :keyword value: The value for this CAA record. + :paramtype value: str + """ super(CaaRecord, self).__init__(**kwargs) self.flags = flags self.tag = tag @@ -89,17 +105,17 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] """ _attribute_map = { @@ -118,6 +134,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -128,8 +157,8 @@ def __init__( class CnameRecord(msrest.serialization.Model): """A CNAME record. - :param cname: The canonical name for this CNAME record. - :type cname: str + :ivar cname: The canonical name for this CNAME record. + :vartype cname: str """ _attribute_map = { @@ -142,6 +171,10 @@ def __init__( cname: Optional[str] = None, **kwargs ): + """ + :keyword cname: The canonical name for this CNAME record. + :paramtype cname: str + """ super(CnameRecord, self).__init__(**kwargs) self.cname = cname @@ -149,10 +182,10 @@ def __init__( class MxRecord(msrest.serialization.Model): """An MX record. - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str + :ivar preference: The preference value for this MX record. + :vartype preference: int + :ivar exchange: The domain name of the mail host for this MX record. + :vartype exchange: str """ _attribute_map = { @@ -167,6 +200,12 @@ def __init__( exchange: Optional[str] = None, **kwargs ): + """ + :keyword preference: The preference value for this MX record. + :paramtype preference: int + :keyword exchange: The domain name of the mail host for this MX record. + :paramtype exchange: str + """ super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange @@ -175,8 +214,8 @@ def __init__( class NsRecord(msrest.serialization.Model): """An NS record. - :param nsdname: The name server name for this NS record. - :type nsdname: str + :ivar nsdname: The name server name for this NS record. + :vartype nsdname: str """ _attribute_map = { @@ -189,6 +228,10 @@ def __init__( nsdname: Optional[str] = None, **kwargs ): + """ + :keyword nsdname: The name server name for this NS record. + :paramtype nsdname: str + """ super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname @@ -196,8 +239,8 @@ def __init__( class PtrRecord(msrest.serialization.Model): """A PTR record. - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str + :ivar ptrdname: The PTR target domain name for this PTR record. + :vartype ptrdname: str """ _attribute_map = { @@ -210,6 +253,10 @@ def __init__( ptrdname: Optional[str] = None, **kwargs ): + """ + :keyword ptrdname: The PTR target domain name for this PTR record. + :paramtype ptrdname: str + """ super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname @@ -225,34 +272,34 @@ class RecordSet(msrest.serialization.Model): :vartype name: str :ivar type: The type of the record set. :vartype type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long + :ivar etag: The etag of the record set. + :vartype etag: str + :ivar metadata: The metadata attached to the record set. + :vartype metadata: dict[str, str] + :ivar ttl: The TTL (time-to-live) of the records in the record set. + :vartype ttl: long :ivar fqdn: Fully qualified domain name of the record set. :vartype fqdn: str - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2018_03_01_preview.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2018_03_01_preview.models.SoaRecord - :param caa_records: The list of CAA records in the record set. - :type caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] + :ivar a_records: The list of A records in the record set. + :vartype a_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] + :ivar aaaa_records: The list of AAAA records in the record set. + :vartype aaaa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.AaaaRecord] + :ivar mx_records: The list of MX records in the record set. + :vartype mx_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.MxRecord] + :ivar ns_records: The list of NS records in the record set. + :vartype ns_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.NsRecord] + :ivar ptr_records: The list of PTR records in the record set. + :vartype ptr_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.PtrRecord] + :ivar srv_records: The list of SRV records in the record set. + :vartype srv_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.SrvRecord] + :ivar txt_records: The list of TXT records in the record set. + :vartype txt_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.TxtRecord] + :ivar cname_record: The CNAME record in the record set. + :vartype cname_record: ~azure.mgmt.dns.v2018_03_01_preview.models.CnameRecord + :ivar soa_record: The SOA record in the record set. + :vartype soa_record: ~azure.mgmt.dns.v2018_03_01_preview.models.SoaRecord + :ivar caa_records: The list of CAA records in the record set. + :vartype caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] """ _validation = { @@ -300,6 +347,34 @@ def __init__( caa_records: Optional[List["CaaRecord"]] = None, **kwargs ): + """ + :keyword etag: The etag of the record set. + :paramtype etag: str + :keyword metadata: The metadata attached to the record set. + :paramtype metadata: dict[str, str] + :keyword ttl: The TTL (time-to-live) of the records in the record set. + :paramtype ttl: long + :keyword a_records: The list of A records in the record set. + :paramtype a_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] + :keyword aaaa_records: The list of AAAA records in the record set. + :paramtype aaaa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.AaaaRecord] + :keyword mx_records: The list of MX records in the record set. + :paramtype mx_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.MxRecord] + :keyword ns_records: The list of NS records in the record set. + :paramtype ns_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.NsRecord] + :keyword ptr_records: The list of PTR records in the record set. + :paramtype ptr_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.PtrRecord] + :keyword srv_records: The list of SRV records in the record set. + :paramtype srv_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.SrvRecord] + :keyword txt_records: The list of TXT records in the record set. + :paramtype txt_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.TxtRecord] + :keyword cname_record: The CNAME record in the record set. + :paramtype cname_record: ~azure.mgmt.dns.v2018_03_01_preview.models.CnameRecord + :keyword soa_record: The SOA record in the record set. + :paramtype soa_record: ~azure.mgmt.dns.v2018_03_01_preview.models.SoaRecord + :keyword caa_records: The list of CAA records in the record set. + :paramtype caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] + """ super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -325,8 +400,8 @@ class RecordSetListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] + :ivar value: Information about the record sets in the response. + :vartype value: list[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -346,6 +421,10 @@ def __init__( value: Optional[List["RecordSet"]] = None, **kwargs ): + """ + :keyword value: Information about the record sets in the response. + :paramtype value: list[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] + """ super(RecordSetListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -354,8 +433,8 @@ def __init__( class RecordSetUpdateParameters(msrest.serialization.Model): """Parameters supplied to update a record set. - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :ivar record_set: Specifies information about the record set being updated. + :vartype record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet """ _attribute_map = { @@ -368,6 +447,10 @@ def __init__( record_set: Optional["RecordSet"] = None, **kwargs ): + """ + :keyword record_set: Specifies information about the record set being updated. + :paramtype record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + """ super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set @@ -403,6 +486,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -412,21 +497,21 @@ def __init__( class SoaRecord(msrest.serialization.Model): """An SOA record. - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to + :ivar host: The domain name of the authoritative name server for this SOA record. + :vartype host: str + :ivar email: The email contact for this SOA record. + :vartype email: str + :ivar serial_number: The serial number for this SOA record. + :vartype serial_number: long + :ivar refresh_time: The refresh value for this SOA record. + :vartype refresh_time: long + :ivar retry_time: The retry time for this SOA record. + :vartype retry_time: long + :ivar expire_time: The expire time for this SOA record. + :vartype expire_time: long + :ivar minimum_ttl: The minimum value for this SOA record. By convention this is used to determine the negative caching duration. - :type minimum_ttl: long + :vartype minimum_ttl: long """ _attribute_map = { @@ -451,6 +536,23 @@ def __init__( minimum_ttl: Optional[int] = None, **kwargs ): + """ + :keyword host: The domain name of the authoritative name server for this SOA record. + :paramtype host: str + :keyword email: The email contact for this SOA record. + :paramtype email: str + :keyword serial_number: The serial number for this SOA record. + :paramtype serial_number: long + :keyword refresh_time: The refresh value for this SOA record. + :paramtype refresh_time: long + :keyword retry_time: The retry time for this SOA record. + :paramtype retry_time: long + :keyword expire_time: The expire time for this SOA record. + :paramtype expire_time: long + :keyword minimum_ttl: The minimum value for this SOA record. By convention this is used to + determine the negative caching duration. + :paramtype minimum_ttl: long + """ super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -464,14 +566,14 @@ def __init__( class SrvRecord(msrest.serialization.Model): """An SRV record. - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str + :ivar priority: The priority value for this SRV record. + :vartype priority: int + :ivar weight: The weight value for this SRV record. + :vartype weight: int + :ivar port: The port value for this SRV record. + :vartype port: int + :ivar target: The target domain name for this SRV record. + :vartype target: str """ _attribute_map = { @@ -490,6 +592,16 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword priority: The priority value for this SRV record. + :paramtype priority: int + :keyword weight: The weight value for this SRV record. + :paramtype weight: int + :keyword port: The port value for this SRV record. + :paramtype port: int + :keyword target: The target domain name for this SRV record. + :paramtype target: str + """ super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -500,8 +612,8 @@ def __init__( class SubResource(msrest.serialization.Model): """A reference to a another resource. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -514,6 +626,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -533,10 +649,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: 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 = { @@ -561,6 +677,12 @@ def __init__( 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 @@ -569,8 +691,8 @@ def __init__( class TxtRecord(msrest.serialization.Model): """A TXT record. - :param value: The text value of this TXT record. - :type value: list[str] + :ivar value: The text value of this TXT record. + :vartype value: list[str] """ _attribute_map = { @@ -583,6 +705,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The text value of this TXT record. + :paramtype value: list[str] + """ super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -602,12 +728,12 @@ class Zone(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The etag of the zone. - :type etag: 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: The etag of the zone. + :vartype etag: str :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype max_number_of_record_sets: long @@ -621,16 +747,17 @@ class Zone(TrackedResource): :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: + :ivar zone_type: The type of this DNS zone (Public or Private). Possible values include: "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneType - :param registration_virtual_networks: A list of references to virtual networks that register + :vartype zone_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneType + :ivar registration_virtual_networks: A list of references to virtual networks that register hostnames in this DNS zone. This is a only when ZoneType is Private. - :type registration_virtual_networks: + :vartype registration_virtual_networks: list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] - :param resolution_virtual_networks: A list of references to virtual networks that resolve + :ivar resolution_virtual_networks: A list of references to virtual networks that resolve records in this DNS zone. This is a only when ZoneType is Private. - :type resolution_virtual_networks: list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] + :vartype resolution_virtual_networks: + list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] """ _validation = { @@ -671,6 +798,25 @@ def __init__( resolution_virtual_networks: 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 etag: The etag of the zone. + :paramtype etag: str + :keyword zone_type: The type of this DNS zone (Public or Private). Possible values include: + "Public", "Private". Default value: "Public". + :paramtype zone_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneType + :keyword registration_virtual_networks: A list of references to virtual networks that register + hostnames in this DNS zone. This is a only when ZoneType is Private. + :paramtype registration_virtual_networks: + list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] + :keyword resolution_virtual_networks: A list of references to virtual networks that resolve + records in this DNS zone. This is a only when ZoneType is Private. + :paramtype resolution_virtual_networks: + list[~azure.mgmt.dns.v2018_03_01_preview.models.SubResource] + """ super(Zone, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.max_number_of_record_sets = None @@ -687,8 +833,8 @@ class ZoneListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] + :ivar value: Information about the DNS zones. + :vartype value: list[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -708,6 +854,10 @@ def __init__( value: Optional[List["Zone"]] = None, **kwargs ): + """ + :keyword value: Information about the DNS zones. + :paramtype value: list[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] + """ super(ZoneListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -716,8 +866,8 @@ def __init__( class ZoneUpdate(msrest.serialization.Model): """Describes a request to update a DNS zone. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -730,5 +880,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ZoneUpdate, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py index b23b481345cb..ce0ad27416f7 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,345 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_create_or_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_delete_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_type_request( + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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_all_by_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if record_set_name_suffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("record_set_name_suffix", record_set_name_suffix, 'str') + _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 + ) class RecordSetsOperations(object): """RecordSetsOperations operations. @@ -45,17 +368,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,7 +393,7 @@ def update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -82,37 +405,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,20 +443,22 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -154,10 +474,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -169,39 +489,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,18 +532,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -243,7 +559,7 @@ def delete( :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -255,32 +571,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -290,17 +602,18 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs: Any + ) -> "_models.RecordSet": """Gets a record set. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -321,30 +634,27 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,18 +667,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, - resource_group_name, # type: str - zone_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -378,57 +690,60 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,7 +752,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,20 +765,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, - resource_group_name, # type: str - zone_name, # type: str - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -467,56 +787,58 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,7 +847,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -534,20 +860,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore + @distributed_trace def list_all_by_dns_zone( self, - resource_group_name, # type: str - zone_name, # type: str - top=None, # type: Optional[int] - record_set_name_suffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -555,56 +882,58 @@ def list_all_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param record_set_name_suffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if record_set_name_suffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("record_set_name_suffix", record_set_name_suffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + template_url=self.list_all_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -613,7 +942,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -622,7 +955,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} # type: ignore + list_all_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py index 0ff736df2b55..40858b4d0321 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,274 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_delete_request_initial( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_update_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _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_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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 + ) class ZonesOperations(object): """ZonesOperations operations. @@ -47,16 +297,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - parameters, # type: "_models.Zone" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,10 +317,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -82,37 +332,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -129,45 +373,42 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore - def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + zone_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', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -177,16 +418,17 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -196,17 +438,21 @@ def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -219,24 +465,18 @@ def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -246,17 +486,17 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + **kwargs: Any + ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -273,28 +513,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,17 +544,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - zone_name, # type: str - parameters, # type: "_models.ZoneUpdate" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + parameters: "_models.ZoneUpdate", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.Zone": """Updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -328,7 +567,7 @@ def update( :type parameters: ~azure.mgmt.dns.v2018_03_01_preview.models.ZoneUpdate :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -340,35 +579,30 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ZoneUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ZoneUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,63 +615,65 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones 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 record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -446,7 +682,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -455,62 +695,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_03_01_preview.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -519,7 +759,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -528,7 +772,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py index a21e1fdf48bb..ae3cd3c5beba 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DnsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py index c046b7b9737d..79a73fbf831f 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class DnsManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the + Microsoft Azure subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-05-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py index 089a1436d217..1dba166be866 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_dns_management_client.py @@ -6,26 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations -from .operations import DnsResourceReferenceOperations from . import models +from ._configuration import DnsManagementClientConfiguration +from .operations import DnsResourceReferenceOperations, RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -33,57 +30,66 @@ class DnsManagementClient(object): :ivar zones: ZonesOperations operations :vartype zones: azure.mgmt.dns.v2018_05_01.operations.ZonesOperations :ivar dns_resource_reference: DnsResourceReferenceOperations operations - :vartype dns_resource_reference: azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations + :vartype dns_resource_reference: + azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the + Microsoft Azure subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DnsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resource_reference = DnsResourceReferenceOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dns_resource_reference = DnsResourceReferenceOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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 diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json index 6715ff309d7c..ed4737b9810c 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "DnsManagementClient", "filename": "_dns_management_client", "description": "The DNS Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "record_sets": "RecordSetsOperations", diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/__init__.py index 1a93fabcef86..8408ffb17ed9 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._dns_management_client import DnsManagementClient __all__ = ['DnsManagementClient'] + +# `._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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py index c2fdc75518e1..47a6d7d1126e 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClientConfiguration(Configuration): +class DnsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class DnsManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the + Microsoft Azure subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DnsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + 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.") - super(DnsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-05-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py index 37e833ed55bb..985c954709fc 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py @@ -6,24 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import DnsManagementClientConfiguration -from .operations import RecordSetsOperations -from .operations import ZonesOperations -from .operations import DnsResourceReferenceOperations from .. import models +from ._configuration import DnsManagementClientConfiguration +from .operations import DnsResourceReferenceOperations, RecordSetsOperations, ZonesOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class DnsManagementClient(object): +class DnsManagementClient: """The DNS Management Client. :ivar record_sets: RecordSetsOperations operations @@ -31,55 +30,66 @@ class DnsManagementClient(object): :ivar zones: ZonesOperations operations :vartype zones: azure.mgmt.dns.v2018_05_01.aio.operations.ZonesOperations :ivar dns_resource_reference: DnsResourceReferenceOperations operations - :vartype dns_resource_reference: azure.mgmt.dns.v2018_05_01.aio.operations.DnsResourceReferenceOperations + :vartype dns_resource_reference: + azure.mgmt.dns.v2018_05_01.aio.operations.DnsResourceReferenceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the + Microsoft Azure subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DnsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DnsManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.record_sets = RecordSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resource_reference = DnsResourceReferenceOperations(self._client, self._config, self._serialize, self._deserialize) - self.record_sets = RecordSetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.zones = ZonesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dns_resource_reference = DnsResourceReferenceOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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() diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_patch.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/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/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py index a254031feeff..4b3d1179c255 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dns_resource_reference_operations import build_get_by_target_resources_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,10 +43,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_target_resources( self, parameters: "_models.DnsResourceReferenceRequest", - **kwargs + **kwargs: Any ) -> "_models.DnsResourceReferenceResult": """Returns the DNS records specified by the referencing targetResourceIds. @@ -59,31 +63,27 @@ async def get_by_target_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_by_target_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DnsResourceReferenceRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResourceReferenceRequest') + + request = build_get_by_target_resources_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.get_by_target_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,4 +96,6 @@ async def get_by_target_resources( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_target_resources.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference'} # type: ignore + + get_by_target_resources.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference"} # type: ignore + diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py index 1f22824ea0b6..23f9878b5657 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._record_sets_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_all_by_dns_zone_request, build_list_by_dns_zone_request, build_list_by_type_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, @@ -49,7 +54,7 @@ async def update( record_type: Union[str, "_models.RecordType"], parameters: "_models.RecordSet", if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Updates a record set within a DNS zone. @@ -65,7 +70,7 @@ async def update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -77,37 +82,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,8 +120,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -131,7 +134,7 @@ async def create_or_update( parameters: "_models.RecordSet", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. @@ -148,10 +151,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -163,39 +166,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -212,16 +209,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. @@ -236,7 +236,7 @@ async def delete( :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -248,32 +248,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -283,15 +279,17 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, relative_record_set_name: str, record_type: Union[str, "_models.RecordType"], - **kwargs + **kwargs: Any ) -> "_models.RecordSet": """Gets a record set. @@ -313,30 +311,27 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,8 +344,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, resource_group_name: str, @@ -358,7 +356,7 @@ def list_by_type( record_type: Union[str, "_models.RecordType"], top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. @@ -369,57 +367,60 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -428,7 +429,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,18 +442,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, resource_group_name: str, zone_name: str, top: Optional[int] = None, recordsetnamesuffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. @@ -457,56 +464,58 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -515,7 +524,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,18 +537,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore + @distributed_trace def list_all_by_dns_zone( self, resource_group_name: str, zone_name: str, top: Optional[int] = None, record_set_name_suffix: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. @@ -544,56 +559,58 @@ def list_all_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param record_set_name_suffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if record_set_name_suffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("record_set_name_suffix", record_set_name_suffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + template_url=self.list_all_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -602,7 +619,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -611,7 +632,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} # type: ignore + list_all_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py index 0a7d6022a51c..31e8855f99e3 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union 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, HttpRequest +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._zones_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +55,7 @@ async def create_or_update( parameters: "_models.Zone", if_match: Optional[str] = None, if_none_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. @@ -62,10 +67,10 @@ async def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -77,37 +82,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -124,44 +123,42 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore - async def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **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', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -171,14 +168,16 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, zone_name: str, if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -189,17 +188,21 @@ async def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -212,24 +215,18 @@ async def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -239,15 +236,16 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, zone_name: str, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. @@ -265,28 +263,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -299,15 +294,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, zone_name: str, parameters: "_models.ZoneUpdate", if_match: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Zone": """Updates a DNS zone. Does not modify DNS records within the zone. @@ -319,7 +317,7 @@ async def update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -331,35 +329,30 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ZoneUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ZoneUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -372,62 +365,66 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,7 +433,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -445,61 +446,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -508,7 +511,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -517,7 +524,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/__init__.py index ecceb3cb0c3b..a6735c9f698a 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/__init__.py @@ -6,52 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARecord - from ._models_py3 import AaaaRecord - from ._models_py3 import CaaRecord - from ._models_py3 import CloudErrorBody - from ._models_py3 import CnameRecord - from ._models_py3 import DnsResourceReference - from ._models_py3 import DnsResourceReferenceRequest - from ._models_py3 import DnsResourceReferenceResult - from ._models_py3 import MxRecord - from ._models_py3 import NsRecord - from ._models_py3 import PtrRecord - from ._models_py3 import RecordSet - from ._models_py3 import RecordSetListResult - from ._models_py3 import RecordSetUpdateParameters - from ._models_py3 import Resource - from ._models_py3 import SoaRecord - from ._models_py3 import SrvRecord - from ._models_py3 import SubResource - from ._models_py3 import TxtRecord - from ._models_py3 import Zone - from ._models_py3 import ZoneListResult - from ._models_py3 import ZoneUpdate -except (SyntaxError, ImportError): - from ._models import ARecord # type: ignore - from ._models import AaaaRecord # type: ignore - from ._models import CaaRecord # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CnameRecord # type: ignore - from ._models import DnsResourceReference # type: ignore - from ._models import DnsResourceReferenceRequest # type: ignore - from ._models import DnsResourceReferenceResult # type: ignore - from ._models import MxRecord # type: ignore - from ._models import NsRecord # type: ignore - from ._models import PtrRecord # type: ignore - from ._models import RecordSet # type: ignore - from ._models import RecordSetListResult # type: ignore - from ._models import RecordSetUpdateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import SoaRecord # type: ignore - from ._models import SrvRecord # type: ignore - from ._models import SubResource # type: ignore - from ._models import TxtRecord # type: ignore - from ._models import Zone # type: ignore - from ._models import ZoneListResult # type: ignore - from ._models import ZoneUpdate # type: ignore +from ._models_py3 import ARecord +from ._models_py3 import AaaaRecord +from ._models_py3 import CaaRecord +from ._models_py3 import CloudErrorBody +from ._models_py3 import CnameRecord +from ._models_py3 import DnsResourceReference +from ._models_py3 import DnsResourceReferenceRequest +from ._models_py3 import DnsResourceReferenceResult +from ._models_py3 import MxRecord +from ._models_py3 import NsRecord +from ._models_py3 import PtrRecord +from ._models_py3 import RecordSet +from ._models_py3 import RecordSetListResult +from ._models_py3 import RecordSetUpdateParameters +from ._models_py3 import Resource +from ._models_py3 import SoaRecord +from ._models_py3 import SrvRecord +from ._models_py3 import SubResource +from ._models_py3 import TxtRecord +from ._models_py3 import Zone +from ._models_py3 import ZoneListResult +from ._models_py3 import ZoneUpdate + from ._dns_management_client_enums import ( RecordType, diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_dns_management_client_enums.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_dns_management_client_enums.py index f2abeece2155..b9c9308e013a 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_dns_management_client_enums.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_dns_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecordType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): A = "A" AAAA = "AAAA" @@ -39,7 +24,7 @@ class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SRV = "SRV" TXT = "TXT" -class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ZoneType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of this DNS zone (Public or Private). """ diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models.py deleted file mode 100644 index eec9fa62b048..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models.py +++ /dev/null @@ -1,694 +0,0 @@ -# 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 msrest.serialization - - -class AaaaRecord(msrest.serialization.Model): - """An AAAA record. - - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str - """ - - _attribute_map = { - 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AaaaRecord, self).__init__(**kwargs) - self.ipv6_address = kwargs.get('ipv6_address', None) - - -class ARecord(msrest.serialization.Model): - """An A record. - - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str - """ - - _attribute_map = { - 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARecord, self).__init__(**kwargs) - self.ipv4_address = kwargs.get('ipv4_address', None) - - -class CaaRecord(msrest.serialization.Model): - """A CAA record. - - :param flags: The flags for this CAA record as an integer between 0 and 255. - :type flags: int - :param tag: The tag for this CAA record. - :type tag: str - :param value: The value for this CAA record. - :type value: str - """ - - _attribute_map = { - 'flags': {'key': 'flags', 'type': 'int'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CaaRecord, self).__init__(**kwargs) - self.flags = kwargs.get('flags', None) - self.tag = kwargs.get('tag', None) - self.value = kwargs.get('value', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in - error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2018_05_01.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, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class CnameRecord(msrest.serialization.Model): - """A CNAME record. - - :param cname: The canonical name for this CNAME record. - :type cname: str - """ - - _attribute_map = { - 'cname': {'key': 'cname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CnameRecord, self).__init__(**kwargs) - self.cname = kwargs.get('cname', None) - - -class DnsResourceReference(msrest.serialization.Model): - """Represents a single Azure resource and its referencing DNS records. - - :param dns_resources: A list of dns Records. - :type dns_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - :param target_resource: A reference to an azure resource from where the dns resource value is - taken. - :type target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource - """ - - _attribute_map = { - 'dns_resources': {'key': 'dnsResources', 'type': '[SubResource]'}, - 'target_resource': {'key': 'targetResource', 'type': 'SubResource'}, - } - - def __init__( - self, - **kwargs - ): - super(DnsResourceReference, self).__init__(**kwargs) - self.dns_resources = kwargs.get('dns_resources', None) - self.target_resource = kwargs.get('target_resource', None) - - -class DnsResourceReferenceRequest(msrest.serialization.Model): - """Represents the properties of the Dns Resource Reference Request. - - :param target_resources: A list of references to azure resources for which referencing dns - records need to be queried. - :type target_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - """ - - _attribute_map = { - 'target_resources': {'key': 'properties.targetResources', 'type': '[SubResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DnsResourceReferenceRequest, self).__init__(**kwargs) - self.target_resources = kwargs.get('target_resources', None) - - -class DnsResourceReferenceResult(msrest.serialization.Model): - """Represents the properties of the Dns Resource Reference Result. - - :param dns_resource_references: The result of dns resource reference request. A list of dns - resource references for each of the azure resource in the request. - :type dns_resource_references: list[~azure.mgmt.dns.v2018_05_01.models.DnsResourceReference] - """ - - _attribute_map = { - 'dns_resource_references': {'key': 'properties.dnsResourceReferences', 'type': '[DnsResourceReference]'}, - } - - def __init__( - self, - **kwargs - ): - super(DnsResourceReferenceResult, self).__init__(**kwargs) - self.dns_resource_references = kwargs.get('dns_resource_references', None) - - -class MxRecord(msrest.serialization.Model): - """An MX record. - - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str - """ - - _attribute_map = { - 'preference': {'key': 'preference', 'type': 'int'}, - 'exchange': {'key': 'exchange', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MxRecord, self).__init__(**kwargs) - self.preference = kwargs.get('preference', None) - self.exchange = kwargs.get('exchange', None) - - -class NsRecord(msrest.serialization.Model): - """An NS record. - - :param nsdname: The name server name for this NS record. - :type nsdname: str - """ - - _attribute_map = { - 'nsdname': {'key': 'nsdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NsRecord, self).__init__(**kwargs) - self.nsdname = kwargs.get('nsdname', None) - - -class PtrRecord(msrest.serialization.Model): - """A PTR record. - - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str - """ - - _attribute_map = { - 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PtrRecord, self).__init__(**kwargs) - self.ptrdname = kwargs.get('ptrdname', None) - - -class RecordSet(msrest.serialization.Model): - """Describes a DNS record set (a collection of DNS records with the same name and type). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the record set. - :vartype id: str - :ivar name: The name of the record set. - :vartype name: str - :ivar type: The type of the record set. - :vartype type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long - :ivar fqdn: Fully qualified domain name of the record set. - :vartype fqdn: str - :ivar provisioning_state: provisioning State of the record set. - :vartype provisioning_state: str - :param target_resource: A reference to an azure resource from where the dns resource value is - taken. - :type target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2018_05_01.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2018_05_01.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2018_05_01.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2018_05_01.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2018_05_01.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2018_05_01.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2018_05_01.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2018_05_01.models.SoaRecord - :param caa_records: The list of CAA records in the record set. - :type caa_records: list[~azure.mgmt.dns.v2018_05_01.models.CaaRecord] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'fqdn': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'ttl': {'key': 'properties.TTL', 'type': 'long'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'target_resource': {'key': 'properties.targetResource', 'type': 'SubResource'}, - 'a_records': {'key': 'properties.ARecords', 'type': '[ARecord]'}, - 'aaaa_records': {'key': 'properties.AAAARecords', 'type': '[AaaaRecord]'}, - 'mx_records': {'key': 'properties.MXRecords', 'type': '[MxRecord]'}, - 'ns_records': {'key': 'properties.NSRecords', 'type': '[NsRecord]'}, - 'ptr_records': {'key': 'properties.PTRRecords', 'type': '[PtrRecord]'}, - 'srv_records': {'key': 'properties.SRVRecords', 'type': '[SrvRecord]'}, - 'txt_records': {'key': 'properties.TXTRecords', 'type': '[TxtRecord]'}, - 'cname_record': {'key': 'properties.CNAMERecord', 'type': 'CnameRecord'}, - 'soa_record': {'key': 'properties.SOARecord', 'type': 'SoaRecord'}, - 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSet, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = kwargs.get('etag', None) - self.metadata = kwargs.get('metadata', None) - self.ttl = kwargs.get('ttl', None) - self.fqdn = None - self.provisioning_state = None - self.target_resource = kwargs.get('target_resource', None) - self.a_records = kwargs.get('a_records', None) - self.aaaa_records = kwargs.get('aaaa_records', None) - self.mx_records = kwargs.get('mx_records', None) - self.ns_records = kwargs.get('ns_records', None) - self.ptr_records = kwargs.get('ptr_records', None) - self.srv_records = kwargs.get('srv_records', None) - self.txt_records = kwargs.get('txt_records', None) - self.cname_record = kwargs.get('cname_record', None) - self.soa_record = kwargs.get('soa_record', None) - self.caa_records = kwargs.get('caa_records', None) - - -class RecordSetListResult(msrest.serialization.Model): - """The response to a record set List operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2018_05_01.models.RecordSet] - :ivar next_link: The continuation token for the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecordSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RecordSetUpdateParameters(msrest.serialization.Model): - """Parameters supplied to update a record set. - - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet - """ - - _attribute_map = { - 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, - } - - def __init__( - self, - **kwargs - ): - super(RecordSetUpdateParameters, self).__init__(**kwargs) - self.record_set = kwargs.get('record_set', None) - - -class Resource(msrest.serialization.Model): - """Common properties of an Azure Resource Manager resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SoaRecord(msrest.serialization.Model): - """An SOA record. - - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to - determine the negative caching duration. - :type minimum_ttl: long - """ - - _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'serial_number': {'key': 'serialNumber', 'type': 'long'}, - 'refresh_time': {'key': 'refreshTime', 'type': 'long'}, - 'retry_time': {'key': 'retryTime', 'type': 'long'}, - 'expire_time': {'key': 'expireTime', 'type': 'long'}, - 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(SoaRecord, self).__init__(**kwargs) - self.host = kwargs.get('host', None) - self.email = kwargs.get('email', None) - self.serial_number = kwargs.get('serial_number', None) - self.refresh_time = kwargs.get('refresh_time', None) - self.retry_time = kwargs.get('retry_time', None) - self.expire_time = kwargs.get('expire_time', None) - self.minimum_ttl = kwargs.get('minimum_ttl', None) - - -class SrvRecord(msrest.serialization.Model): - """An SRV record. - - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str - """ - - _attribute_map = { - 'priority': {'key': 'priority', 'type': 'int'}, - 'weight': {'key': 'weight', 'type': 'int'}, - 'port': {'key': 'port', 'type': 'int'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SrvRecord, self).__init__(**kwargs) - self.priority = kwargs.get('priority', None) - self.weight = kwargs.get('weight', None) - self.port = kwargs.get('port', None) - self.target = kwargs.get('target', None) - - -class SubResource(msrest.serialization.Model): - """A reference to a another resource. - - :param id: Resource Id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class TxtRecord(msrest.serialization.Model): - """A TXT record. - - :param value: The text value of this TXT record. - :type value: list[str] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TxtRecord, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Zone(Resource): - """Describes a DNS zone. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: The etag of the zone. - :type etag: str - :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this - DNS zone. This is a read-only property and any attempt to set this value will be ignored. - :vartype max_number_of_record_sets: long - :ivar max_number_of_records_per_record_set: The maximum number of records per record set that - can be created in this DNS zone. This is a read-only property and any attempt to set this - value will be ignored. - :vartype max_number_of_records_per_record_set: long - :ivar number_of_record_sets: The current number of record sets in this DNS zone. This is a - read-only property and any attempt to set this value will be ignored. - :vartype number_of_record_sets: long - :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any - attempt to set this value will be ignored. - :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: - "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2018_05_01.models.ZoneType - :param registration_virtual_networks: A list of references to virtual networks that register - hostnames in this DNS zone. This is a only when ZoneType is Private. - :type registration_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - :param resolution_virtual_networks: A list of references to virtual networks that resolve - records in this DNS zone. This is a only when ZoneType is Private. - :type resolution_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'max_number_of_record_sets': {'readonly': True}, - 'max_number_of_records_per_record_set': {'readonly': True}, - 'number_of_record_sets': {'readonly': True}, - 'name_servers': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'max_number_of_record_sets': {'key': 'properties.maxNumberOfRecordSets', 'type': 'long'}, - 'max_number_of_records_per_record_set': {'key': 'properties.maxNumberOfRecordsPerRecordSet', 'type': 'long'}, - 'number_of_record_sets': {'key': 'properties.numberOfRecordSets', 'type': 'long'}, - 'name_servers': {'key': 'properties.nameServers', 'type': '[str]'}, - 'zone_type': {'key': 'properties.zoneType', 'type': 'str'}, - 'registration_virtual_networks': {'key': 'properties.registrationVirtualNetworks', 'type': '[SubResource]'}, - 'resolution_virtual_networks': {'key': 'properties.resolutionVirtualNetworks', 'type': '[SubResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(Zone, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.max_number_of_record_sets = None - self.max_number_of_records_per_record_set = None - self.number_of_record_sets = None - self.name_servers = None - self.zone_type = kwargs.get('zone_type', "Public") - self.registration_virtual_networks = kwargs.get('registration_virtual_networks', None) - self.resolution_virtual_networks = kwargs.get('resolution_virtual_networks', None) - - -class ZoneListResult(msrest.serialization.Model): - """The response to a Zone List or ListAll operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2018_05_01.models.Zone] - :ivar next_link: The continuation token for the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Zone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ZoneUpdate(msrest.serialization.Model): - """Describes a request to update a DNS zone. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ZoneUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py index c6c2406e6a63..49c553326b66 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_models_py3.py @@ -16,8 +16,8 @@ class AaaaRecord(msrest.serialization.Model): """An AAAA record. - :param ipv6_address: The IPv6 address of this AAAA record. - :type ipv6_address: str + :ivar ipv6_address: The IPv6 address of this AAAA record. + :vartype ipv6_address: str """ _attribute_map = { @@ -30,6 +30,10 @@ def __init__( ipv6_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv6_address: The IPv6 address of this AAAA record. + :paramtype ipv6_address: str + """ super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address @@ -37,8 +41,8 @@ def __init__( class ARecord(msrest.serialization.Model): """An A record. - :param ipv4_address: The IPv4 address of this A record. - :type ipv4_address: str + :ivar ipv4_address: The IPv4 address of this A record. + :vartype ipv4_address: str """ _attribute_map = { @@ -51,6 +55,10 @@ def __init__( ipv4_address: Optional[str] = None, **kwargs ): + """ + :keyword ipv4_address: The IPv4 address of this A record. + :paramtype ipv4_address: str + """ super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address @@ -58,12 +66,12 @@ def __init__( class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and 255. - :type flags: int - :param tag: The tag for this CAA record. - :type tag: str - :param value: The value for this CAA record. - :type value: str + :ivar flags: The flags for this CAA record as an integer between 0 and 255. + :vartype flags: int + :ivar tag: The tag for this CAA record. + :vartype tag: str + :ivar value: The value for this CAA record. + :vartype value: str """ _attribute_map = { @@ -80,6 +88,14 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword flags: The flags for this CAA record as an integer between 0 and 255. + :paramtype flags: int + :keyword tag: The tag for this CAA record. + :paramtype tag: str + :keyword value: The value for this CAA record. + :paramtype value: str + """ super(CaaRecord, self).__init__(**kwargs) self.flags = flags self.tag = tag @@ -89,17 +105,17 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param target: The target of the particular error. For example, the name of the property in + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in error. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody] """ _attribute_map = { @@ -118,6 +134,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -128,8 +157,8 @@ def __init__( class CnameRecord(msrest.serialization.Model): """A CNAME record. - :param cname: The canonical name for this CNAME record. - :type cname: str + :ivar cname: The canonical name for this CNAME record. + :vartype cname: str """ _attribute_map = { @@ -142,6 +171,10 @@ def __init__( cname: Optional[str] = None, **kwargs ): + """ + :keyword cname: The canonical name for this CNAME record. + :paramtype cname: str + """ super(CnameRecord, self).__init__(**kwargs) self.cname = cname @@ -149,11 +182,11 @@ def __init__( class DnsResourceReference(msrest.serialization.Model): """Represents a single Azure resource and its referencing DNS records. - :param dns_resources: A list of dns Records. - :type dns_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - :param target_resource: A reference to an azure resource from where the dns resource value is + :ivar dns_resources: A list of dns Records. + :vartype dns_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :ivar target_resource: A reference to an azure resource from where the dns resource value is taken. - :type target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource + :vartype target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource """ _attribute_map = { @@ -168,6 +201,13 @@ def __init__( target_resource: Optional["SubResource"] = None, **kwargs ): + """ + :keyword dns_resources: A list of dns Records. + :paramtype dns_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :keyword target_resource: A reference to an azure resource from where the dns resource value is + taken. + :paramtype target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource + """ super(DnsResourceReference, self).__init__(**kwargs) self.dns_resources = dns_resources self.target_resource = target_resource @@ -176,9 +216,9 @@ def __init__( class DnsResourceReferenceRequest(msrest.serialization.Model): """Represents the properties of the Dns Resource Reference Request. - :param target_resources: A list of references to azure resources for which referencing dns + :ivar target_resources: A list of references to azure resources for which referencing dns records need to be queried. - :type target_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :vartype target_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] """ _attribute_map = { @@ -191,6 +231,11 @@ def __init__( target_resources: Optional[List["SubResource"]] = None, **kwargs ): + """ + :keyword target_resources: A list of references to azure resources for which referencing dns + records need to be queried. + :paramtype target_resources: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + """ super(DnsResourceReferenceRequest, self).__init__(**kwargs) self.target_resources = target_resources @@ -198,9 +243,9 @@ def __init__( class DnsResourceReferenceResult(msrest.serialization.Model): """Represents the properties of the Dns Resource Reference Result. - :param dns_resource_references: The result of dns resource reference request. A list of dns + :ivar dns_resource_references: The result of dns resource reference request. A list of dns resource references for each of the azure resource in the request. - :type dns_resource_references: list[~azure.mgmt.dns.v2018_05_01.models.DnsResourceReference] + :vartype dns_resource_references: list[~azure.mgmt.dns.v2018_05_01.models.DnsResourceReference] """ _attribute_map = { @@ -213,6 +258,12 @@ def __init__( dns_resource_references: Optional[List["DnsResourceReference"]] = None, **kwargs ): + """ + :keyword dns_resource_references: The result of dns resource reference request. A list of dns + resource references for each of the azure resource in the request. + :paramtype dns_resource_references: + list[~azure.mgmt.dns.v2018_05_01.models.DnsResourceReference] + """ super(DnsResourceReferenceResult, self).__init__(**kwargs) self.dns_resource_references = dns_resource_references @@ -220,10 +271,10 @@ def __init__( class MxRecord(msrest.serialization.Model): """An MX record. - :param preference: The preference value for this MX record. - :type preference: int - :param exchange: The domain name of the mail host for this MX record. - :type exchange: str + :ivar preference: The preference value for this MX record. + :vartype preference: int + :ivar exchange: The domain name of the mail host for this MX record. + :vartype exchange: str """ _attribute_map = { @@ -238,6 +289,12 @@ def __init__( exchange: Optional[str] = None, **kwargs ): + """ + :keyword preference: The preference value for this MX record. + :paramtype preference: int + :keyword exchange: The domain name of the mail host for this MX record. + :paramtype exchange: str + """ super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange @@ -246,8 +303,8 @@ def __init__( class NsRecord(msrest.serialization.Model): """An NS record. - :param nsdname: The name server name for this NS record. - :type nsdname: str + :ivar nsdname: The name server name for this NS record. + :vartype nsdname: str """ _attribute_map = { @@ -260,6 +317,10 @@ def __init__( nsdname: Optional[str] = None, **kwargs ): + """ + :keyword nsdname: The name server name for this NS record. + :paramtype nsdname: str + """ super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname @@ -267,8 +328,8 @@ def __init__( class PtrRecord(msrest.serialization.Model): """A PTR record. - :param ptrdname: The PTR target domain name for this PTR record. - :type ptrdname: str + :ivar ptrdname: The PTR target domain name for this PTR record. + :vartype ptrdname: str """ _attribute_map = { @@ -281,6 +342,10 @@ def __init__( ptrdname: Optional[str] = None, **kwargs ): + """ + :keyword ptrdname: The PTR target domain name for this PTR record. + :paramtype ptrdname: str + """ super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname @@ -296,39 +361,39 @@ class RecordSet(msrest.serialization.Model): :vartype name: str :ivar type: The type of the record set. :vartype type: str - :param etag: The etag of the record set. - :type etag: str - :param metadata: The metadata attached to the record set. - :type metadata: dict[str, str] - :param ttl: The TTL (time-to-live) of the records in the record set. - :type ttl: long + :ivar etag: The etag of the record set. + :vartype etag: str + :ivar metadata: The metadata attached to the record set. + :vartype metadata: dict[str, str] + :ivar ttl: The TTL (time-to-live) of the records in the record set. + :vartype ttl: long :ivar fqdn: Fully qualified domain name of the record set. :vartype fqdn: str :ivar provisioning_state: provisioning State of the record set. :vartype provisioning_state: str - :param target_resource: A reference to an azure resource from where the dns resource value is + :ivar target_resource: A reference to an azure resource from where the dns resource value is taken. - :type target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource - :param a_records: The list of A records in the record set. - :type a_records: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] - :param aaaa_records: The list of AAAA records in the record set. - :type aaaa_records: list[~azure.mgmt.dns.v2018_05_01.models.AaaaRecord] - :param mx_records: The list of MX records in the record set. - :type mx_records: list[~azure.mgmt.dns.v2018_05_01.models.MxRecord] - :param ns_records: The list of NS records in the record set. - :type ns_records: list[~azure.mgmt.dns.v2018_05_01.models.NsRecord] - :param ptr_records: The list of PTR records in the record set. - :type ptr_records: list[~azure.mgmt.dns.v2018_05_01.models.PtrRecord] - :param srv_records: The list of SRV records in the record set. - :type srv_records: list[~azure.mgmt.dns.v2018_05_01.models.SrvRecord] - :param txt_records: The list of TXT records in the record set. - :type txt_records: list[~azure.mgmt.dns.v2018_05_01.models.TxtRecord] - :param cname_record: The CNAME record in the record set. - :type cname_record: ~azure.mgmt.dns.v2018_05_01.models.CnameRecord - :param soa_record: The SOA record in the record set. - :type soa_record: ~azure.mgmt.dns.v2018_05_01.models.SoaRecord - :param caa_records: The list of CAA records in the record set. - :type caa_records: list[~azure.mgmt.dns.v2018_05_01.models.CaaRecord] + :vartype target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource + :ivar a_records: The list of A records in the record set. + :vartype a_records: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] + :ivar aaaa_records: The list of AAAA records in the record set. + :vartype aaaa_records: list[~azure.mgmt.dns.v2018_05_01.models.AaaaRecord] + :ivar mx_records: The list of MX records in the record set. + :vartype mx_records: list[~azure.mgmt.dns.v2018_05_01.models.MxRecord] + :ivar ns_records: The list of NS records in the record set. + :vartype ns_records: list[~azure.mgmt.dns.v2018_05_01.models.NsRecord] + :ivar ptr_records: The list of PTR records in the record set. + :vartype ptr_records: list[~azure.mgmt.dns.v2018_05_01.models.PtrRecord] + :ivar srv_records: The list of SRV records in the record set. + :vartype srv_records: list[~azure.mgmt.dns.v2018_05_01.models.SrvRecord] + :ivar txt_records: The list of TXT records in the record set. + :vartype txt_records: list[~azure.mgmt.dns.v2018_05_01.models.TxtRecord] + :ivar cname_record: The CNAME record in the record set. + :vartype cname_record: ~azure.mgmt.dns.v2018_05_01.models.CnameRecord + :ivar soa_record: The SOA record in the record set. + :vartype soa_record: ~azure.mgmt.dns.v2018_05_01.models.SoaRecord + :ivar caa_records: The list of CAA records in the record set. + :vartype caa_records: list[~azure.mgmt.dns.v2018_05_01.models.CaaRecord] """ _validation = { @@ -380,6 +445,37 @@ def __init__( caa_records: Optional[List["CaaRecord"]] = None, **kwargs ): + """ + :keyword etag: The etag of the record set. + :paramtype etag: str + :keyword metadata: The metadata attached to the record set. + :paramtype metadata: dict[str, str] + :keyword ttl: The TTL (time-to-live) of the records in the record set. + :paramtype ttl: long + :keyword target_resource: A reference to an azure resource from where the dns resource value is + taken. + :paramtype target_resource: ~azure.mgmt.dns.v2018_05_01.models.SubResource + :keyword a_records: The list of A records in the record set. + :paramtype a_records: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] + :keyword aaaa_records: The list of AAAA records in the record set. + :paramtype aaaa_records: list[~azure.mgmt.dns.v2018_05_01.models.AaaaRecord] + :keyword mx_records: The list of MX records in the record set. + :paramtype mx_records: list[~azure.mgmt.dns.v2018_05_01.models.MxRecord] + :keyword ns_records: The list of NS records in the record set. + :paramtype ns_records: list[~azure.mgmt.dns.v2018_05_01.models.NsRecord] + :keyword ptr_records: The list of PTR records in the record set. + :paramtype ptr_records: list[~azure.mgmt.dns.v2018_05_01.models.PtrRecord] + :keyword srv_records: The list of SRV records in the record set. + :paramtype srv_records: list[~azure.mgmt.dns.v2018_05_01.models.SrvRecord] + :keyword txt_records: The list of TXT records in the record set. + :paramtype txt_records: list[~azure.mgmt.dns.v2018_05_01.models.TxtRecord] + :keyword cname_record: The CNAME record in the record set. + :paramtype cname_record: ~azure.mgmt.dns.v2018_05_01.models.CnameRecord + :keyword soa_record: The SOA record in the record set. + :paramtype soa_record: ~azure.mgmt.dns.v2018_05_01.models.SoaRecord + :keyword caa_records: The list of CAA records in the record set. + :paramtype caa_records: list[~azure.mgmt.dns.v2018_05_01.models.CaaRecord] + """ super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -407,8 +503,8 @@ class RecordSetListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Information about the record sets in the response. - :type value: list[~azure.mgmt.dns.v2018_05_01.models.RecordSet] + :ivar value: Information about the record sets in the response. + :vartype value: list[~azure.mgmt.dns.v2018_05_01.models.RecordSet] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -428,6 +524,10 @@ def __init__( value: Optional[List["RecordSet"]] = None, **kwargs ): + """ + :keyword value: Information about the record sets in the response. + :paramtype value: list[~azure.mgmt.dns.v2018_05_01.models.RecordSet] + """ super(RecordSetListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -436,8 +536,8 @@ def __init__( class RecordSetUpdateParameters(msrest.serialization.Model): """Parameters supplied to update a record set. - :param record_set: Specifies information about the record set being updated. - :type record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :ivar record_set: Specifies information about the record set being updated. + :vartype record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet """ _attribute_map = { @@ -450,6 +550,10 @@ def __init__( record_set: Optional["RecordSet"] = None, **kwargs ): + """ + :keyword record_set: Specifies information about the record set being updated. + :paramtype record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + """ super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set @@ -467,10 +571,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -495,6 +599,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -506,21 +616,21 @@ def __init__( class SoaRecord(msrest.serialization.Model): """An SOA record. - :param host: The domain name of the authoritative name server for this SOA record. - :type host: str - :param email: The email contact for this SOA record. - :type email: str - :param serial_number: The serial number for this SOA record. - :type serial_number: long - :param refresh_time: The refresh value for this SOA record. - :type refresh_time: long - :param retry_time: The retry time for this SOA record. - :type retry_time: long - :param expire_time: The expire time for this SOA record. - :type expire_time: long - :param minimum_ttl: The minimum value for this SOA record. By convention this is used to + :ivar host: The domain name of the authoritative name server for this SOA record. + :vartype host: str + :ivar email: The email contact for this SOA record. + :vartype email: str + :ivar serial_number: The serial number for this SOA record. + :vartype serial_number: long + :ivar refresh_time: The refresh value for this SOA record. + :vartype refresh_time: long + :ivar retry_time: The retry time for this SOA record. + :vartype retry_time: long + :ivar expire_time: The expire time for this SOA record. + :vartype expire_time: long + :ivar minimum_ttl: The minimum value for this SOA record. By convention this is used to determine the negative caching duration. - :type minimum_ttl: long + :vartype minimum_ttl: long """ _attribute_map = { @@ -545,6 +655,23 @@ def __init__( minimum_ttl: Optional[int] = None, **kwargs ): + """ + :keyword host: The domain name of the authoritative name server for this SOA record. + :paramtype host: str + :keyword email: The email contact for this SOA record. + :paramtype email: str + :keyword serial_number: The serial number for this SOA record. + :paramtype serial_number: long + :keyword refresh_time: The refresh value for this SOA record. + :paramtype refresh_time: long + :keyword retry_time: The retry time for this SOA record. + :paramtype retry_time: long + :keyword expire_time: The expire time for this SOA record. + :paramtype expire_time: long + :keyword minimum_ttl: The minimum value for this SOA record. By convention this is used to + determine the negative caching duration. + :paramtype minimum_ttl: long + """ super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -558,14 +685,14 @@ def __init__( class SrvRecord(msrest.serialization.Model): """An SRV record. - :param priority: The priority value for this SRV record. - :type priority: int - :param weight: The weight value for this SRV record. - :type weight: int - :param port: The port value for this SRV record. - :type port: int - :param target: The target domain name for this SRV record. - :type target: str + :ivar priority: The priority value for this SRV record. + :vartype priority: int + :ivar weight: The weight value for this SRV record. + :vartype weight: int + :ivar port: The port value for this SRV record. + :vartype port: int + :ivar target: The target domain name for this SRV record. + :vartype target: str """ _attribute_map = { @@ -584,6 +711,16 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword priority: The priority value for this SRV record. + :paramtype priority: int + :keyword weight: The weight value for this SRV record. + :paramtype weight: int + :keyword port: The port value for this SRV record. + :paramtype port: int + :keyword target: The target domain name for this SRV record. + :paramtype target: str + """ super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -594,8 +731,8 @@ def __init__( class SubResource(msrest.serialization.Model): """A reference to a another resource. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -608,6 +745,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -615,8 +756,8 @@ def __init__( class TxtRecord(msrest.serialization.Model): """A TXT record. - :param value: The text value of this TXT record. - :type value: list[str] + :ivar value: The text value of this TXT record. + :vartype value: list[str] """ _attribute_map = { @@ -629,6 +770,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The text value of this TXT record. + :paramtype value: list[str] + """ super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -646,12 +791,12 @@ class Zone(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param etag: The etag of the zone. - :type etag: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar etag: The etag of the zone. + :vartype etag: str :ivar max_number_of_record_sets: The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype max_number_of_record_sets: long @@ -665,15 +810,15 @@ class Zone(Resource): :ivar name_servers: The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored. :vartype name_servers: list[str] - :param zone_type: The type of this DNS zone (Public or Private). Possible values include: + :ivar zone_type: The type of this DNS zone (Public or Private). Possible values include: "Public", "Private". Default value: "Public". - :type zone_type: str or ~azure.mgmt.dns.v2018_05_01.models.ZoneType - :param registration_virtual_networks: A list of references to virtual networks that register + :vartype zone_type: str or ~azure.mgmt.dns.v2018_05_01.models.ZoneType + :ivar registration_virtual_networks: A list of references to virtual networks that register hostnames in this DNS zone. This is a only when ZoneType is Private. - :type registration_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] - :param resolution_virtual_networks: A list of references to virtual networks that resolve + :vartype registration_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :ivar resolution_virtual_networks: A list of references to virtual networks that resolve records in this DNS zone. This is a only when ZoneType is Private. - :type resolution_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :vartype resolution_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] """ _validation = { @@ -714,6 +859,23 @@ def __init__( resolution_virtual_networks: Optional[List["SubResource"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword etag: The etag of the zone. + :paramtype etag: str + :keyword zone_type: The type of this DNS zone (Public or Private). Possible values include: + "Public", "Private". Default value: "Public". + :paramtype zone_type: str or ~azure.mgmt.dns.v2018_05_01.models.ZoneType + :keyword registration_virtual_networks: A list of references to virtual networks that register + hostnames in this DNS zone. This is a only when ZoneType is Private. + :paramtype registration_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + :keyword resolution_virtual_networks: A list of references to virtual networks that resolve + records in this DNS zone. This is a only when ZoneType is Private. + :paramtype resolution_virtual_networks: list[~azure.mgmt.dns.v2018_05_01.models.SubResource] + """ super(Zone, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.max_number_of_record_sets = None @@ -730,8 +892,8 @@ class ZoneListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Information about the DNS zones. - :type value: list[~azure.mgmt.dns.v2018_05_01.models.Zone] + :ivar value: Information about the DNS zones. + :vartype value: list[~azure.mgmt.dns.v2018_05_01.models.Zone] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -751,6 +913,10 @@ def __init__( value: Optional[List["Zone"]] = None, **kwargs ): + """ + :keyword value: Information about the DNS zones. + :paramtype value: list[~azure.mgmt.dns.v2018_05_01.models.Zone] + """ super(ZoneListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -759,8 +925,8 @@ def __init__( class ZoneUpdate(msrest.serialization.Model): """Describes a request to update a DNS zone. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -773,5 +939,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ZoneUpdate, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py index a69e3bd8f53d..145497a5a7e7 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_dns_resource_reference_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,64 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_get_by_target_resources_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _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 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="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class DnsResourceReferenceOperations(object): """DnsResourceReferenceOperations operations. @@ -44,12 +87,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_target_resources( self, - parameters, # type: "_models.DnsResourceReferenceRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.DnsResourceReferenceResult" + parameters: "_models.DnsResourceReferenceRequest", + **kwargs: Any + ) -> "_models.DnsResourceReferenceResult": """Returns the DNS records specified by the referencing targetResourceIds. :param parameters: Properties for dns resource reference request. @@ -64,31 +107,27 @@ def get_by_target_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_by_target_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DnsResourceReferenceRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DnsResourceReferenceRequest') + + request = build_get_by_target_resources_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.get_by_target_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,4 +140,6 @@ def get_by_target_resources( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_target_resources.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference'} # type: ignore + + get_by_target_resources.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference"} # type: ignore + diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py index 7c9b6ec708a0..6152d45b7857 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_record_sets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,345 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _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_create_or_update_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _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_delete_request( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _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( + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "relativeRecordSetName": _SERIALIZER.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _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_type_request( + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "recordType": _SERIALIZER.url("record_type", record_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if recordsetnamesuffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("recordsetnamesuffix", recordsetnamesuffix, 'str') + _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_all_by_dns_zone_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if record_set_name_suffix is not None: + _query_parameters['$recordsetnamesuffix'] = _SERIALIZER.query("record_set_name_suffix", record_set_name_suffix, 'str') + _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 + ) class RecordSetsOperations(object): """RecordSetsOperations operations. @@ -45,17 +368,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. @@ -70,7 +393,7 @@ def update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -82,37 +405,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,20 +443,22 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - parameters, # type: "_models.RecordSet" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.RecordSet": """Creates or updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. @@ -154,10 +474,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.RecordSet :param if_match: The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will be ignored. + updating an existing record set. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecordSet, or the result of cls(response) @@ -169,39 +489,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RecordSet') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RecordSet') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,18 +532,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: """Deletes a record set from a DNS zone. This operation cannot be undone. :param resource_group_name: The name of the resource group. @@ -243,7 +559,7 @@ def delete( :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param if_match: The etag of the record set. Omit this value to always delete the current record set. Specify the last-seen etag value to prevent accidentally deleting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -255,32 +571,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -290,17 +602,18 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - relative_record_set_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecordSet" + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs: Any + ) -> "_models.RecordSet": """Gets a record set. :param resource_group_name: The name of the resource group. @@ -321,30 +634,27 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'relativeRecordSetName': self._serialize.url("relative_record_set_name", relative_record_set_name, 'str', skip_quote=True), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + relative_record_set_name=relative_record_set_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,18 +667,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}"} # type: ignore + + + @distributed_trace def list_by_type( self, - resource_group_name, # type: str - zone_name, # type: str - record_type, # type: Union[str, "_models.RecordType"] - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists the record sets of a specified type in a DNS zone. :param resource_group_name: The name of the resource group. @@ -378,57 +690,59 @@ def list_by_type( :param record_type: The type of record sets to enumerate. :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'recordType': self._serialize.url("record_type", record_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + record_type=record_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -437,7 +751,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,20 +764,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}"} # type: ignore + @distributed_trace def list_by_dns_zone( self, - resource_group_name, # type: str - zone_name, # type: str - top=None, # type: Optional[int] - recordsetnamesuffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. @@ -467,56 +786,57 @@ def list_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param recordsetnamesuffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type recordsetnamesuffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if recordsetnamesuffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("recordsetnamesuffix", recordsetnamesuffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + template_url=self.list_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + recordsetnamesuffix=recordsetnamesuffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,7 +845,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -534,20 +858,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + list_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets"} # type: ignore + @distributed_trace def list_all_by_dns_zone( self, - resource_group_name, # type: str - zone_name, # type: str - top=None, # type: Optional[int] - record_set_name_suffix=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RecordSetListResult"] + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + record_set_name_suffix: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RecordSetListResult"]: """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. @@ -555,56 +880,57 @@ def list_all_by_dns_zone( :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :param record_set_name_suffix: The suffix label of the record set name that has to be used to filter the record set enumerations. If this parameter is specified, Enumeration will return - only records that end with .:code:``. + only records that end with .:code:``. Default value is None. :type record_set_name_suffix: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecordSetListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all_by_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if record_set_name_suffix is not None: - query_parameters['$recordsetnamesuffix'] = self._serialize.query("record_set_name_suffix", record_set_name_suffix, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + template_url=self.list_all_by_dns_zone.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_by_dns_zone_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + record_set_name_suffix=record_set_name_suffix, + 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('RecordSetListResult', pipeline_response) + deserialized = self._deserialize("RecordSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -613,7 +939,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -622,7 +952,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} # type: ignore + list_all_by_dns_zone.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all"} # type: ignore diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py index f3b78d9cff35..c824047ed64c 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/_zones_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,274 @@ # 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 TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer 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 HttpRequest, HttpResponse +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 .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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_delete_request_initial( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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( + resource_group_name: str, + zone_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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_update_request( + resource_group_name: str, + zone_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "zoneName": _SERIALIZER.url("zone_name", zone_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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, + *, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _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 + ) class ZonesOperations(object): """ZonesOperations operations. @@ -47,16 +297,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - zone_name, # type: str - parameters, # type: "_models.Zone" - if_match=None, # type: Optional[str] - if_none_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.Zone": """Creates or updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. @@ -67,10 +317,10 @@ def create_or_update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.Zone :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new DNS zone to be created, but to prevent updating - an existing zone. Other values will be ignored. + an existing zone. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -82,37 +332,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if if_none_match is not None: - header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Zone') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Zone') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -129,45 +373,42 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore - def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + zone_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', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -177,16 +418,17 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - zone_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. @@ -196,17 +438,21 @@ def begin_delete( :type zone_name: str :param if_match: The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes. + Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :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. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -219,24 +465,18 @@ def begin_delete( resource_group_name=resource_group_name, zone_name=zone_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -246,17 +486,17 @@ def get_long_running_output(pipeline_response): 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/dnsZones/{zoneName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - zone_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + **kwargs: Any + ) -> "_models.Zone": """Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. :param resource_group_name: The name of the resource group. @@ -273,28 +513,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,17 +544,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - zone_name, # type: str - parameters, # type: "_models.ZoneUpdate" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Zone" + resource_group_name: str, + zone_name: str, + parameters: "_models.ZoneUpdate", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.Zone": """Updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. @@ -328,7 +567,7 @@ def update( :type parameters: ~azure.mgmt.dns.v2018_05_01.models.ZoneUpdate :param if_match: The etag of the DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen etag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Zone, or the result of cls(response) @@ -340,35 +579,30 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'zoneName': self._serialize.url("zone_name", zone_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ZoneUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ZoneUpdate') + + request = build_update_request( + resource_group_name=resource_group_name, + zone_name=zone_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,63 +615,65 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + resource_group_name: str, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param top: The maximum number of record sets to return. If not specified, returns up to 100 - record sets. + record sets. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -446,7 +682,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -455,62 +695,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones"} # type: ignore + @distributed_trace def list( self, - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ZoneListResult"] + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ZoneListResult"]: """Lists the DNS zones in all resource groups in a subscription. :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 - zones. + zones. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ZoneListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dns.v2018_05_01.models.ZoneListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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('ZoneListResult', pipeline_response) + deserialized = self._deserialize("ZoneListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -519,7 +759,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -528,7 +772,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones"} # type: ignore