diff --git a/sdk/network/azure-mgmt-dns/CHANGELOG.md b/sdk/network/azure-mgmt-dns/CHANGELOG.md index 884461ddaf44..987a49dde648 100644 --- a/sdk/network/azure-mgmt-dns/CHANGELOG.md +++ b/sdk/network/azure-mgmt-dns/CHANGELOG.md @@ -1,5 +1,37 @@ # Release History +## 8.0.0b1 (2021-03-10) + +This is beta preview version. +For detailed changelog please refer to equivalent stable version 10.2.0 (https://pypi.org/project/azure-mgmt-network/10.2.0/) + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +**General breaking changes** + +- Credential system has been completly revamped: + + - `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/ + - `credentials` parameter has been renamed `credential` + +- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of + supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) +- You can't import a `version` module anymore, use `__version__` instead +- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`. +- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed). +- Most of the operation kwarg have changed. Some of the most noticeable: + + - `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user + - For a complete set of + supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) + +**General new features** + +- Type annotations support using `typing`. SDKs are mypy ready. +- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client. +- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview. + + ## 3.0.0 (2019-06-18) **General Breaking changes** diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/__init__.py index e492c24b0aaf..34fbcbfae313 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/__init__.py @@ -1,19 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DnsManagementClientConfiguration from ._dns_management_client import DnsManagementClient -__all__ = ['DnsManagementClient', 'DnsManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['DnsManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 5f82572692d1..7396cc41e019 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_configuration.py @@ -8,42 +8,59 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration +from typing import Any -from .version import VERSION +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from ._version import VERSION + + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. -class DnsManagementClientConfiguration(AzureConfiguration): - """Configuration for DnsManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Specifies the Azure subscription ID, which - uniquely identifies the Microsoft Azure subscription. + :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. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' - - super(DnsManagementClientConfiguration, self).__init__(base_url) + super(DnsManagementClientConfiguration, self).__init__(**kwargs) - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-dns/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(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 50147031080b..1a6a08032b3b 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 @@ -9,41 +9,41 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient +from azure.mgmt.core import ARMPipelineClient from msrest import Serializer, Deserializer from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import DnsManagementClientConfiguration +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass - -class DnsManagementClient(MultiApiClientMixin, SDKClient): +class DnsManagementClient(MultiApiClientMixin, _SDKClient): """The DNS Management Client. - This ready contains multiple API versions, to help you deal with all Azure clouds + This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). - By default, uses latest API version available on public Azure. - For production, you should stick a particular api-version and/or profile. - The profile sets a mapping between the operation group and an API version. + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. The api-version parameter sets the default API version if the operation group is not described in the profile. - :ivar config: Configuration for client. - :vartype config: DnsManagementClientConfiguration - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription credentials which uniquely identify - Microsoft Azure subscription. The subscription ID forms part of the URI - for every service call. + :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. :type subscription_id: str :param str api_version: API version to use if no profile is provided, or if missing in profile. :param str base_url: Service URL :param profile: A profile definition, from KnownProfiles to dict. :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ DEFAULT_API_VERSION = '2018-05-01' @@ -55,11 +55,20 @@ class DnsManagementClient(MultiApiClientMixin, SDKClient): _PROFILE_TAG + " latest" ) - def __init__(self, credentials, subscription_id, api_version=None, base_url=None, profile=KnownProfiles.default): - self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url) + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + api_version=None, + base_url=None, + profile=KnownProfiles.default, + **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__( - credentials, - self.config, api_version=api_version, profile=profile ) @@ -85,7 +94,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2018-05-01': from .v2018_05_01 import models return models - raise NotImplementedError("APIVersion {} is not available".format(api_version)) + raise ValueError("API version {} is not available".format(api_version)) @property def dns_resource_reference(self): @@ -97,8 +106,8 @@ def dns_resource_reference(self): if api_version == '2018-05-01': from .v2018_05_01.operations import DnsResourceReferenceOperations as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) - return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + raise ValueError("API version {} does not have operation group 'dns_resource_reference'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property def record_sets(self): @@ -116,8 +125,8 @@ def record_sets(self): elif api_version == '2018-05-01': from .v2018_05_01.operations import RecordSetsOperations as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) - return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + raise ValueError("API version {} does not have operation group 'record_sets'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property def zones(self): @@ -135,5 +144,13 @@ def zones(self): elif api_version == '2018-05-01': from .v2018_05_01.operations import ZonesOperations as OperationClass else: - raise NotImplementedError("APIVersion {} is not available".format(api_version)) - return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + raise ValueError("API version {} does not have operation group 'zones'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + def close(self): + self._client.close() + def __enter__(self): + self._client.__enter__() + return self + def __exit__(self, *exc_details): + self._client.__exit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/version.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py similarity index 95% rename from sdk/network/azure-mgmt-dns/azure/mgmt/dns/version.py rename to sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py index 7f225c6aab41..7cf3ebf6b364 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/_version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "8.0.0b1" 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/aio/__init__.py similarity index 74% rename from sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/version.py rename to sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/__init__.py index 5bfc801ce220..1a93fabcef86 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/version.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/__init__.py @@ -1,13 +1,10 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2018-05-01" - +from ._dns_management_client import DnsManagementClient +__all__ = ['DnsManagementClient'] 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 new file mode 100644 index 000000000000..638315361f84 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_configuration.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "AsyncTokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ) -> None: + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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 new file mode 100644 index 000000000000..d462215a5947 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/aio/_dns_management_client.py @@ -0,0 +1,156 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Serializer, Deserializer + +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin +from ._configuration import DnsManagementClientConfiguration + +class _SDKClient(object): + def __init__(self, *args, **kwargs): + """This is a fake class to support current implemetation of MultiApiClientMixin." + Will be removed in final version of multiapi azure-core based client + """ + pass + +class DnsManagementClient(MultiApiClientMixin, _SDKClient): + """The DNS Management Client. + + This ready contains multiple API versions, to help you deal with all of the Azure clouds + (Azure Stack, Azure Government, Azure China, etc.). + By default, it uses the latest API version available on public Azure. + For production, you should stick to a particular api-version and/or profile. + The profile sets a mapping between an operation group and its API version. + The api-version parameter sets the default API version if the operation + group is not described in the profile. + + :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. + :type subscription_id: str + :param str api_version: API version to use if no profile is provided, or if + missing in profile. + :param str base_url: Service URL + :param profile: A profile definition, from KnownProfiles to dict. + :type profile: azure.profiles.KnownProfiles + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + DEFAULT_API_VERSION = '2018-05-01' + _PROFILE_TAG = "azure.mgmt.dns.DnsManagementClient" + LATEST_PROFILE = ProfileDefinition({ + _PROFILE_TAG: { + None: DEFAULT_API_VERSION, + }}, + _PROFILE_TAG + " latest" + ) + + def __init__( + self, + credential, # type: "AsyncTokenCredential" + subscription_id, # type: str + api_version=None, + base_url=None, + profile=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__( + api_version=api_version, + profile=profile + ) + + @classmethod + def _models_dict(cls, api_version): + return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} + + @classmethod + def models(cls, api_version=DEFAULT_API_VERSION): + """Module depends on the API version: + + * 2016-04-01: :mod:`v2016_04_01.models` + * 2018-03-01-preview: :mod:`v2018_03_01_preview.models` + * 2018-05-01: :mod:`v2018_05_01.models` + """ + if api_version == '2016-04-01': + from ..v2016_04_01 import models + return models + elif api_version == '2018-03-01-preview': + from ..v2018_03_01_preview import models + return models + elif api_version == '2018-05-01': + from ..v2018_05_01 import models + return models + raise ValueError("API version {} is not available".format(api_version)) + + @property + def dns_resource_reference(self): + """Instance depends on the API version: + + * 2018-05-01: :class:`DnsResourceReferenceOperations` + """ + api_version = self._get_api_version('dns_resource_reference') + if api_version == '2018-05-01': + from ..v2018_05_01.aio.operations import DnsResourceReferenceOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dns_resource_reference'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def record_sets(self): + """Instance depends on the API version: + + * 2016-04-01: :class:`RecordSetsOperations` + * 2018-03-01-preview: :class:`RecordSetsOperations` + * 2018-05-01: :class:`RecordSetsOperations` + """ + api_version = self._get_api_version('record_sets') + if api_version == '2016-04-01': + from ..v2016_04_01.aio.operations import RecordSetsOperations as OperationClass + elif api_version == '2018-03-01-preview': + from ..v2018_03_01_preview.aio.operations import RecordSetsOperations as OperationClass + elif api_version == '2018-05-01': + from ..v2018_05_01.aio.operations import RecordSetsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'record_sets'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def zones(self): + """Instance depends on the API version: + + * 2016-04-01: :class:`ZonesOperations` + * 2018-03-01-preview: :class:`ZonesOperations` + * 2018-05-01: :class:`ZonesOperations` + """ + api_version = self._get_api_version('zones') + if api_version == '2016-04-01': + from ..v2016_04_01.aio.operations import ZonesOperations as OperationClass + elif api_version == '2018-03-01-preview': + from ..v2018_03_01_preview.aio.operations import ZonesOperations as OperationClass + elif api_version == '2018-05-01': + from ..v2018_05_01.aio.operations import ZonesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'zones'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + async def close(self): + await self._client.close() + async def __aenter__(self): + await self._client.__aenter__() + return self + async def __aexit__(self, *exc_details): + await self._client.__aexit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/py.typed b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 e492c24b0aaf..34fbcbfae313 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 @@ -1,19 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DnsManagementClientConfiguration from ._dns_management_client import DnsManagementClient -__all__ = ['DnsManagementClient', 'DnsManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['DnsManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 d5b022705bad..3e19ebde305a 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 @@ -1,48 +1,70 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. -class DnsManagementClientConfiguration(AzureConfiguration): - """Configuration for DnsManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(DnsManagementClientConfiguration, self).__init__(**kwargs) - super(DnsManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-dns/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-04-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(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 aa992dcb47b1..13bedd153c42 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 @@ -1,16 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import 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 ._configuration import DnsManagementClientConfiguration from .operations import RecordSetsOperations @@ -18,37 +23,53 @@ from . import models -class DnsManagementClient(SDKClient): +class DnsManagementClient(object): """The DNS Management Client. - :ivar config: Configuration for client. - :vartype config: DnsManagementClientConfiguration - - :ivar record_sets: RecordSets operations + :ivar record_sets: RecordSetsOperations operations :vartype record_sets: azure.mgmt.dns.v2016_04_01.operations.RecordSetsOperations - :ivar zones: Zones operations + :ivar zones: ZonesOperations operations :vartype zones: azure.mgmt.dns.v2016_04_01.operations.ZonesOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str :param 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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url) - super(DnsManagementClient, self).__init__(self.config.credentials, self.config) + 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) + 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.api_version = '2016-04-01' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.record_sets = RecordSetsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.zones = ZonesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DnsManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..27c5318d2873 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2016-04-01", + "total_api_version_list": ["2016-04-01"], + "client": { + "name": "DnsManagementClient", + "filename": "_dns_management_client", + "description": "The DNS Management Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "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 + }, + "operation_groups": { + "record_sets": "RecordSetsOperations", + "zones": "ZonesOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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/aio/__init__.py similarity index 74% rename from sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/version.py rename to sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/__init__.py index 5ddeb1e4b90a..1a93fabcef86 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/aio/__init__.py @@ -1,13 +1,10 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2016-04-01" - +from ._dns_management_client import DnsManagementClient +__all__ = ['DnsManagementClient'] 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 new file mode 100644 index 000000000000..18caafafa738 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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 new file mode 100644 index 000000000000..0d012267c513 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/_dns_management_client.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +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 ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations +from .operations import ZonesOperations +from .. import models + + +class DnsManagementClient(object): + """The DNS Management Client. + + :ivar record_sets: RecordSetsOperations operations + :vartype record_sets: azure.mgmt.dns.v2016_04_01.aio.operations.RecordSetsOperations + :ivar zones: ZonesOperations operations + :vartype zones: azure.mgmt.dns.v2016_04_01.aio.operations.ZonesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param 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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + 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.record_sets = RecordSetsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DnsManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/__init__.py new file mode 100644 index 000000000000..caab83d882c4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._record_sets_operations import RecordSetsOperations +from ._zones_operations import ZonesOperations + +__all__ = [ + 'RecordSetsOperations', + 'ZonesOperations', +] 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 new file mode 100644 index 000000000000..4fbf21039d25 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_record_sets_operations.py @@ -0,0 +1,530 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RecordSetsOperations: + """RecordSetsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2016_04_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType + :param parameters: Parameters supplied to the Update operation. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def delete( + 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 + ) -> 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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs + ) -> "_models.RecordSet": + """Gets a record set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.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') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + def list_by_type( + self, + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + + def list_by_dns_zone( + self, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_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. + :type resource_group_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_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 new file mode 100644 index 000000000000..8f3209b48d45 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/aio/operations/_zones_operations.py @@ -0,0 +1,458 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ZonesOperations: + """ZonesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2016_04_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Zone', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 + ) -> 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') + + # 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ZoneDeleteResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["_models.ZoneDeleteResult"]: + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ZoneDeleteResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneDeleteResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + + def list( + self, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/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 7fee7bca9579..4f52b8ef8668 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 @@ -1,79 +1,81 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AaaaRecord from ._models_py3 import ARecord - from ._models_py3 import AzureEntityResource + 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 ProxyResource 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 AaaaRecord - from ._models import ARecord - from ._models import AzureEntityResource - from ._models import CnameRecord - from ._models import MxRecord - from ._models import NsRecord - from ._models import ProxyResource - from ._models import PtrRecord - from ._models import RecordSet - from ._models import RecordSetUpdateParameters - from ._models import Resource - from ._models import SoaRecord - from ._models import SrvRecord - from ._models import TrackedResource - from ._models import TxtRecord - from ._models import Zone - from ._models import ZoneDeleteResult -from ._paged_models import RecordSetPaged -from ._paged_models import ZonePaged + 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 ._dns_management_client_enums import ( - OperationStatus, HttpStatusCode, + OperationStatus, RecordType, + ZoneType, ) __all__ = [ - 'AaaaRecord', 'ARecord', - 'AzureEntityResource', + 'AaaaRecord', + 'CloudErrorBody', 'CnameRecord', 'MxRecord', 'NsRecord', - 'ProxyResource', 'PtrRecord', 'RecordSet', + 'RecordSetListResult', 'RecordSetUpdateParameters', 'Resource', 'SoaRecord', 'SrvRecord', + 'SubResource', 'TrackedResource', 'TxtRecord', 'Zone', 'ZoneDeleteResult', - 'RecordSetPaged', - 'ZonePaged', - 'OperationStatus', + 'ZoneListResult', 'HttpStatusCode', + 'OperationStatus', 'RecordType', + 'ZoneType', ] 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 8417b67339b5..d3200a6666eb 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 @@ -1,83 +1,102 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) -class OperationStatus(str, Enum): + 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) - in_progress = "InProgress" - succeeded = "Succeeded" - failed = "Failed" +class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class HttpStatusCode(str, Enum): + CONTINUE_ENUM = "Continue" + SWITCHING_PROTOCOLS = "SwitchingProtocols" + OK = "OK" + CREATED = "Created" + ACCEPTED = "Accepted" + NON_AUTHORITATIVE_INFORMATION = "NonAuthoritativeInformation" + NO_CONTENT = "NoContent" + RESET_CONTENT = "ResetContent" + PARTIAL_CONTENT = "PartialContent" + MULTIPLE_CHOICES = "MultipleChoices" + AMBIGUOUS = "Ambiguous" + MOVED_PERMANENTLY = "MovedPermanently" + MOVED = "Moved" + FOUND = "Found" + REDIRECT = "Redirect" + SEE_OTHER = "SeeOther" + REDIRECT_METHOD = "RedirectMethod" + NOT_MODIFIED = "NotModified" + USE_PROXY = "UseProxy" + UNUSED = "Unused" + TEMPORARY_REDIRECT = "TemporaryRedirect" + REDIRECT_KEEP_VERB = "RedirectKeepVerb" + BAD_REQUEST = "BadRequest" + UNAUTHORIZED = "Unauthorized" + PAYMENT_REQUIRED = "PaymentRequired" + FORBIDDEN = "Forbidden" + NOT_FOUND = "NotFound" + METHOD_NOT_ALLOWED = "MethodNotAllowed" + NOT_ACCEPTABLE = "NotAcceptable" + PROXY_AUTHENTICATION_REQUIRED = "ProxyAuthenticationRequired" + REQUEST_TIMEOUT = "RequestTimeout" + CONFLICT = "Conflict" + GONE = "Gone" + LENGTH_REQUIRED = "LengthRequired" + PRECONDITION_FAILED = "PreconditionFailed" + REQUEST_ENTITY_TOO_LARGE = "RequestEntityTooLarge" + REQUEST_URI_TOO_LONG = "RequestUriTooLong" + UNSUPPORTED_MEDIA_TYPE = "UnsupportedMediaType" + REQUESTED_RANGE_NOT_SATISFIABLE = "RequestedRangeNotSatisfiable" + EXPECTATION_FAILED = "ExpectationFailed" + UPGRADE_REQUIRED = "UpgradeRequired" + INTERNAL_SERVER_ERROR = "InternalServerError" + NOT_IMPLEMENTED = "NotImplemented" + BAD_GATEWAY = "BadGateway" + SERVICE_UNAVAILABLE = "ServiceUnavailable" + GATEWAY_TIMEOUT = "GatewayTimeout" + HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" - continue_enum = "Continue" - switching_protocols = "SwitchingProtocols" - ok = "OK" - created = "Created" - accepted = "Accepted" - non_authoritative_information = "NonAuthoritativeInformation" - no_content = "NoContent" - reset_content = "ResetContent" - partial_content = "PartialContent" - multiple_choices = "MultipleChoices" - ambiguous = "Ambiguous" - moved_permanently = "MovedPermanently" - moved = "Moved" - found = "Found" - redirect = "Redirect" - see_other = "SeeOther" - redirect_method = "RedirectMethod" - not_modified = "NotModified" - use_proxy = "UseProxy" - unused = "Unused" - temporary_redirect = "TemporaryRedirect" - redirect_keep_verb = "RedirectKeepVerb" - bad_request = "BadRequest" - unauthorized = "Unauthorized" - payment_required = "PaymentRequired" - forbidden = "Forbidden" - not_found = "NotFound" - method_not_allowed = "MethodNotAllowed" - not_acceptable = "NotAcceptable" - proxy_authentication_required = "ProxyAuthenticationRequired" - request_timeout = "RequestTimeout" - conflict = "Conflict" - gone = "Gone" - length_required = "LengthRequired" - precondition_failed = "PreconditionFailed" - request_entity_too_large = "RequestEntityTooLarge" - request_uri_too_long = "RequestUriTooLong" - unsupported_media_type = "UnsupportedMediaType" - requested_range_not_satisfiable = "RequestedRangeNotSatisfiable" - expectation_failed = "ExpectationFailed" - upgrade_required = "UpgradeRequired" - internal_server_error = "InternalServerError" - not_implemented = "NotImplemented" - bad_gateway = "BadGateway" - service_unavailable = "ServiceUnavailable" - gateway_timeout = "GatewayTimeout" - http_version_not_supported = "HttpVersionNotSupported" +class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" -class RecordType(str, Enum): +class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - a = "A" - aaaa = "AAAA" - cname = "CNAME" - mx = "MX" - ns = "NS" - ptr = "PTR" - soa = "SOA" - srv = "SRV" - txt = "TXT" + A = "A" + AAAA = "AAAA" + CNAME = "CNAME" + MX = "MX" + NS = "NS" + PTR = "PTR" + SOA = "SOA" + SRV = "SRV" + TXT = "TXT" + +class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of this DNS zone (Public or Private). + """ + + PUBLIC = "Public" + PRIVATE = "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 index fccceaa82d1a..31cf91caa65f 100644 --- 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 @@ -1,19 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AaaaRecord(Model): +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +20,15 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = kwargs.get('ipv6_address', None) -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,122 +39,27 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = kwargs.get('ipv4_address', None) -class Resource(Model): - """Resource. +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - 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. Ex- - 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 AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CloudError(Model): - """CloudError. - - :param error: - :type error: ~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """CloudErrorBody. - - :param code: + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: + :param details: A list of additional details about the error. :type details: list[~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody] """ @@ -166,7 +70,10 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -174,7 +81,7 @@ def __init__(self, **kwargs): self.details = kwargs.get('details', None) -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -185,12 +92,15 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = kwargs.get('cname', None) -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -204,13 +114,16 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = kwargs.get('preference', None) self.exchange = kwargs.get('exchange', None) -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -221,45 +134,15 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = kwargs.get('nsdname', None) -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ProxyResource, self).__init__(**kwargs) - - -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -270,14 +153,18 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = kwargs.get('ptrdname', None) -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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 @@ -291,8 +178,10 @@ class RecordSet(Model): :type metadata: dict[str, str] :param ttl: The TTL (time-to-live) of the records in the record set. :type ttl: long - :param arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] + :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. @@ -311,6 +200,10 @@ class RecordSet(Model): :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'}, @@ -318,7 +211,8 @@ class RecordSet(Model): 'etag': {'key': 'etag', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, 'ttl': {'key': 'properties.TTL', 'type': 'long'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -329,7 +223,10 @@ class RecordSet(Model): 'soa_record': {'key': 'properties.SOARecord', 'type': 'SoaRecord'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -337,7 +234,8 @@ def __init__(self, **kwargs): self.etag = kwargs.get('etag', None) self.metadata = kwargs.get('metadata', None) self.ttl = kwargs.get('ttl', None) - self.arecords = kwargs.get('arecords', 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) @@ -348,11 +246,33 @@ def __init__(self, **kwargs): self.soa_record = kwargs.get('soa_record', None) -class RecordSetUpdateParameters(Model): +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. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet """ @@ -360,16 +280,55 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = kwargs.get('record_set', None) -class SoaRecord(Model): +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. + :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 @@ -381,8 +340,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -396,7 +355,10 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = kwargs.get('host', None) self.email = kwargs.get('email', None) @@ -407,7 +369,7 @@ def __init__(self, **kwargs): self.minimum_ttl = kwargs.get('minimum_ttl', None) -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -427,7 +389,10 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = kwargs.get('priority', None) self.weight = kwargs.get('weight', None) @@ -435,7 +400,7 @@ def __init__(self, **kwargs): self.target = kwargs.get('target', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. :param id: Resource Id. @@ -446,30 +411,32 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level 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. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -488,13 +455,16 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -505,7 +475,10 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -513,36 +486,40 @@ def __init__(self, **kwargs): class Zone(TrackedResource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :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. + :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 - :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 + :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 = { @@ -550,6 +527,7 @@ class Zone(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'max_number_of_records_per_record_set': {'readonly': True}, 'name_servers': {'readonly': True}, } @@ -561,57 +539,85 @@ class Zone(TrackedResource): '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): + 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(Model): +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. + :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' + :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 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': 'OperationStatus'}, - 'status_code': {'key': 'statusCode', 'type': 'HttpStatusCode'}, + 'status': {'key': 'status', 'type': 'str'}, + 'status_code': {'key': 'statusCode', 'type': 'str'}, 'request_id': {'key': 'requestId', 'type': 'str'}, } - def __init__(self, **kwargs): + 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 896a715c6452..8a2078aacd66 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 @@ -1,19 +1,19 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AaaaRecord(Model): +from ._dns_management_client_enums import * + + +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +24,17 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, *, ipv6_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv6_address: Optional[str] = None, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,122 +45,29 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, *, ipv4_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv4_address: Optional[str] = None, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address -class Resource(Model): - """Resource. - - 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. Ex- - 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) -> None: - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CloudError(Model): - """CloudError. - - :param error: - :type error: ~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """CloudErrorBody. - - :param code: + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: + :param details: A list of additional details about the error. :type details: list[~azure.mgmt.dns.v2016_04_01.models.CloudErrorBody] """ @@ -166,7 +78,15 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, *, code: str=None, message: str=None, target: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -174,7 +94,7 @@ def __init__(self, *, code: str=None, message: str=None, target: str=None, detai self.details = details -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -185,12 +105,17 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, *, cname: str=None, **kwargs) -> None: + def __init__( + self, + *, + cname: Optional[str] = None, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = cname -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -204,13 +129,19 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, *, preference: int=None, exchange: str=None, **kwargs) -> None: + def __init__( + self, + *, + preference: Optional[int] = None, + exchange: Optional[str] = None, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -221,45 +152,17 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, *, nsdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + nsdname: Optional[str] = None, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - 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) -> None: - super(ProxyResource, self).__init__(**kwargs) - - -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -270,14 +173,20 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, *, ptrdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + ptrdname: Optional[str] = None, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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 @@ -291,8 +200,10 @@ class RecordSet(Model): :type metadata: dict[str, str] :param ttl: The TTL (time-to-live) of the records in the record set. :type ttl: long - :param arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2016_04_01.models.ARecord] + :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. @@ -311,6 +222,10 @@ class RecordSet(Model): :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'}, @@ -318,7 +233,8 @@ class RecordSet(Model): 'etag': {'key': 'etag', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, 'ttl': {'key': 'properties.TTL', 'type': 'long'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -329,7 +245,26 @@ class RecordSet(Model): 'soa_record': {'key': 'properties.SOARecord', 'type': 'SoaRecord'}, } - def __init__(self, *, id: str=None, name: str=None, type: str=None, etag: str=None, metadata=None, ttl: int=None, arecords=None, aaaa_records=None, mx_records=None, ns_records=None, ptr_records=None, srv_records=None, txt_records=None, cname_record=None, soa_record=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + type: Optional[str] = None, + etag: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + ttl: Optional[int] = None, + a_records: Optional[List["ARecord"]] = None, + aaaa_records: Optional[List["AaaaRecord"]] = None, + mx_records: Optional[List["MxRecord"]] = None, + ns_records: Optional[List["NsRecord"]] = None, + ptr_records: Optional[List["PtrRecord"]] = None, + srv_records: Optional[List["SrvRecord"]] = None, + txt_records: Optional[List["TxtRecord"]] = None, + cname_record: Optional["CnameRecord"] = None, + soa_record: Optional["SoaRecord"] = None, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = id self.name = name @@ -337,7 +272,8 @@ def __init__(self, *, id: str=None, name: str=None, type: str=None, etag: str=No self.etag = etag self.metadata = metadata self.ttl = ttl - self.arecords = arecords + self.fqdn = None + self.a_records = a_records self.aaaa_records = aaaa_records self.mx_records = mx_records self.ns_records = ns_records @@ -348,11 +284,36 @@ def __init__(self, *, id: str=None, name: str=None, type: str=None, etag: str=No self.soa_record = soa_record -class RecordSetUpdateParameters(Model): +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, + *, + value: Optional[List["RecordSet"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(RecordSetListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RecordSetUpdateParameters(msrest.serialization.Model): """Parameters supplied to update a record set. - :param record_set: Specifies information about the record set being - updated. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2016_04_01.models.RecordSet """ @@ -360,16 +321,57 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, *, record_set=None, **kwargs) -> None: + def __init__( + self, + *, + record_set: Optional["RecordSet"] = None, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set -class SoaRecord(Model): +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. + :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 @@ -381,8 +383,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -396,7 +398,18 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, refresh_time: int=None, retry_time: int=None, expire_time: int=None, minimum_ttl: int=None, **kwargs) -> None: + def __init__( + self, + *, + host: Optional[str] = None, + email: Optional[str] = None, + serial_number: Optional[int] = None, + refresh_time: Optional[int] = None, + retry_time: Optional[int] = None, + expire_time: Optional[int] = None, + minimum_ttl: Optional[int] = None, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -407,7 +420,7 @@ def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, self.minimum_ttl = minimum_ttl -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -427,7 +440,15 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, *, priority: int=None, weight: int=None, port: int=None, target: str=None, **kwargs) -> None: + def __init__( + self, + *, + priority: Optional[int] = None, + weight: Optional[int] = None, + port: Optional[int] = None, + target: Optional[str] = None, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -435,7 +456,7 @@ def __init__(self, *, priority: int=None, weight: int=None, port: int=None, targ self.target = target -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. :param id: Resource Id. @@ -446,30 +467,34 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level 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. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -488,13 +513,19 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, *, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -505,7 +536,12 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List[str]] = None, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -513,36 +549,40 @@ def __init__(self, *, value=None, **kwargs) -> None: class Zone(TrackedResource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :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. + :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 - :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 + :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 = { @@ -550,6 +590,7 @@ class Zone(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'max_number_of_records_per_record_set': {'readonly': True}, 'name_servers': {'readonly': True}, } @@ -561,57 +602,100 @@ class Zone(TrackedResource): '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, *, location: str, tags=None, etag: str=None, max_number_of_record_sets: int=None, number_of_record_sets: int=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + max_number_of_record_sets: Optional[int] = None, + number_of_record_sets: Optional[int] = None, + zone_type: Optional[Union[str, "ZoneType"]] = "Public", + **kwargs + ): super(Zone, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.max_number_of_record_sets = max_number_of_record_sets + self.max_number_of_records_per_record_set = None self.number_of_record_sets = number_of_record_sets self.name_servers = None + self.zone_type = zone_type -class ZoneDeleteResult(Model): +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. + :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' + :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 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': 'OperationStatus'}, - 'status_code': {'key': 'statusCode', 'type': 'HttpStatusCode'}, + 'status': {'key': 'status', 'type': 'str'}, + 'status_code': {'key': 'statusCode', 'type': 'str'}, 'request_id': {'key': 'requestId', 'type': 'str'}, } - def __init__(self, *, azure_async_operation: str=None, status=None, status_code=None, request_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + azure_async_operation: Optional[str] = None, + status: Optional[Union[str, "OperationStatus"]] = None, + status_code: Optional[Union[str, "HttpStatusCode"]] = None, + request_id: Optional[str] = None, + **kwargs + ): super(ZoneDeleteResult, self).__init__(**kwargs) self.azure_async_operation = azure_async_operation self.status = status self.status_code = status_code self.request_id = request_id + + +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, + *, + value: Optional[List["Zone"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/models/_paged_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_paged_models.py deleted file mode 100644 index 360e5e9978a3..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/models/_paged_models.py +++ /dev/null @@ -1,40 +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. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class RecordSetPaged(Paged): - """ - A paging container for iterating over a list of :class:`RecordSet ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RecordSet]'} - } - - def __init__(self, *args, **kwargs): - - super(RecordSetPaged, self).__init__(*args, **kwargs) -class ZonePaged(Paged): - """ - A paging container for iterating over a list of :class:`Zone ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Zone]'} - } - - def __init__(self, *args, **kwargs): - - super(ZonePaged, self).__init__(*args, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/__init__.py index cc23646a5b90..caab83d882c4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._record_sets_operations import RecordSetsOperations 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 6800d71fd657..932e496155e1 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,543 +1,540 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat -from .. import models +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]] class RecordSetsOperations(object): """RecordSetsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2016_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-04-01". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-04-01" - - self.config = config + self._config = config def update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + 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" """Updates a record set within a DNS zone. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', - 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2016_04_01.models.RecordType + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType :param parameters: Parameters supplied to the Update operation. :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def create_or_update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): + 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" """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA can be updated but not created (they are created when - the DNS zone is created). Possible values include: 'A', 'AAAA', - 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2016_04_01.models.RecordType - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def delete( - self, resource_group_name, zone_name, relative_record_set_name, record_type, if_match=None, custom_headers=None, raw=False, **operation_config): + 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 """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA cannot be deleted (they are deleted when the DNS zone - is deleted). Possible values include: 'A', 'AAAA', 'CNAME', 'MX', - 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :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. + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + accept = "application/json" + # Construct URL - url = self.delete.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def get( - self, resource_group_name, zone_name, relative_record_set_name, record_type, custom_headers=None, raw=False, **operation_config): + 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" """Gets a record set. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', - 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2016_04_01.models.RecordType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type record_type: str or ~azure.mgmt.dns.v2016_04_01.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.get.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def list_by_type( - self, resource_group_name, zone_name, record_type, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param record_type: The type of record sets to enumerate. Possible - values include: 'A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', - 'TXT' - :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. + :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. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2016_04_01.models.RecordSetPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] - :raises: :class:`CloudError` + :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 """ + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} + return ItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore def list_by_dns_zone( - self, resource_group_name, zone_name, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists all record sets in a DNS zone. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2016_04_01.models.RecordSetPaged[~azure.mgmt.dns.v2016_04_01.models.RecordSet] - :raises: :class:`CloudError` + :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 """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} + return ItemPaged( + get_next, extract_data + ) + 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 506ebe243e26..108b43d0cf5a 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,440 +1,468 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +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]] class ZonesOperations(object): """ZonesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2016_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-04-01". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-04-01" - - self.config = config + self._config = config def create_or_update( - self, resource_group_name, zone_name, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): - """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. + 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" + """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. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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'] + 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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'Zone') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def _delete_initial( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + zone_name, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> 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.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ZoneDeleteResult', response) + deserialized = self._deserialize('ZoneDeleteResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def delete( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a DNS zone. WARNING: All DNS records in the zone will also be - deleted. This operation cannot be undone. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + 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"] + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns ZoneDeleteResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ZoneDeleteResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dns.v2016_04_01.models.ZoneDeleteResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - zone_name=zone_name, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ZoneDeleteResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ZoneDeleteResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ZoneDeleteResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + 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) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def get( - self, resource_group_name, zone_name, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + zone_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2016_04_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.get.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2016_04_01.models.ZonePaged[~azure.mgmt.dns.v2016_04_01.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore def list( - self, top=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 + zones. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2016_04_01.models.ZonePaged[~azure.mgmt.dns.v2016_04_01.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} + return ItemPaged( + get_next, extract_data + ) + 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/py.typed b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2016_04_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 e492c24b0aaf..34fbcbfae313 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 @@ -1,19 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DnsManagementClientConfiguration from ._dns_management_client import DnsManagementClient -__all__ = ['DnsManagementClient', 'DnsManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['DnsManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 d5b022705bad..4b85d275a3f7 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 @@ -1,48 +1,70 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. -class DnsManagementClientConfiguration(AzureConfiguration): - """Configuration for DnsManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(DnsManagementClientConfiguration, self).__init__(**kwargs) - super(DnsManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-dns/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-03-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(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 563a5ddbf99c..fcf6ccb9f8f0 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 @@ -1,16 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import 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 ._configuration import DnsManagementClientConfiguration from .operations import RecordSetsOperations @@ -18,37 +23,53 @@ from . import models -class DnsManagementClient(SDKClient): +class DnsManagementClient(object): """The DNS Management Client. - :ivar config: Configuration for client. - :vartype config: DnsManagementClientConfiguration - - :ivar record_sets: RecordSets operations + :ivar record_sets: RecordSetsOperations operations :vartype record_sets: azure.mgmt.dns.v2018_03_01_preview.operations.RecordSetsOperations - :ivar zones: Zones operations + :ivar zones: ZonesOperations operations :vartype zones: azure.mgmt.dns.v2018_03_01_preview.operations.ZonesOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str :param 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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url) - super(DnsManagementClient, self).__init__(self.config.credentials, self.config) + 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) + 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.api_version = '2018-03-01-preview' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.record_sets = RecordSetsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.zones = ZonesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DnsManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..2f92fab3ba2d --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/_metadata.json @@ -0,0 +1,62 @@ +{ + "chosen_version": "2018-03-01-preview", + "total_api_version_list": ["2018-03-01-preview"], + "client": { + "name": "DnsManagementClient", + "filename": "_dns_management_client", + "description": "The DNS Management Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "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 + }, + "operation_groups": { + "record_sets": "RecordSetsOperations", + "zones": "ZonesOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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/aio/__init__.py similarity index 74% rename from sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/version.py rename to sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/__init__.py index 623d610ecc13..1a93fabcef86 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/aio/__init__.py @@ -1,13 +1,10 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2018-03-01-preview" - +from ._dns_management_client import DnsManagementClient +__all__ = ['DnsManagementClient'] 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 new file mode 100644 index 000000000000..bdbb814ae1ed --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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 new file mode 100644 index 000000000000..561216f16f3a --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/_dns_management_client.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +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 ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations +from .operations import ZonesOperations +from .. import models + + +class DnsManagementClient(object): + """The DNS Management Client. + + :ivar record_sets: RecordSetsOperations operations + :vartype record_sets: azure.mgmt.dns.v2018_03_01_preview.aio.operations.RecordSetsOperations + :ivar zones: ZonesOperations operations + :vartype zones: azure.mgmt.dns.v2018_03_01_preview.aio.operations.ZonesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param 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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + 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.record_sets = RecordSetsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.zones = ZonesOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DnsManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..caab83d882c4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._record_sets_operations import RecordSetsOperations +from ._zones_operations import ZonesOperations + +__all__ = [ + 'RecordSetsOperations', + 'ZonesOperations', +] 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 new file mode 100644 index 000000000000..bccc0caaa891 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_record_sets_operations.py @@ -0,0 +1,617 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RecordSetsOperations: + """RecordSetsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_03_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :param parameters: Parameters supplied to the Update operation. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def delete( + 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 + ) -> 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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs + ) -> "_models.RecordSet": + """Gets a record set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.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') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + def list_by_type( + self, + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + + def list_by_dns_zone( + self, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_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. + :type resource_group_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + + 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 + ) -> AsyncIterable["_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. + :type resource_group_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_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 new file mode 100644 index 000000000000..3da380ae47e4 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/aio/operations/_zones_operations.py @@ -0,0 +1,523 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ZonesOperations: + """ZonesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_03_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Zone', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 + ) -> 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') + + # 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + 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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + zone_name: str, + parameters: "_models.ZoneUpdate", + if_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param parameters: Parameters supplied to the Update operation. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + + def list( + self, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/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 8d950c092247..3d5d2b3afee4 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 @@ -1,25 +1,22 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AaaaRecord from ._models_py3 import ARecord - from ._models_py3 import AzureEntityResource + 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 ProxyResource 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 @@ -28,45 +25,46 @@ 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 AaaaRecord - from ._models import ARecord - from ._models import AzureEntityResource - from ._models import CaaRecord - from ._models import CnameRecord - from ._models import MxRecord - from ._models import NsRecord - from ._models import ProxyResource - from ._models import PtrRecord - from ._models import RecordSet - from ._models import RecordSetUpdateParameters - from ._models import Resource - from ._models import SoaRecord - from ._models import SrvRecord - from ._models import SubResource - from ._models import TrackedResource - from ._models import TxtRecord - from ._models import Zone - from ._models import ZoneUpdate -from ._paged_models import RecordSetPaged -from ._paged_models import ZonePaged + 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 ._dns_management_client_enums import ( - ZoneType, RecordType, + ZoneType, ) __all__ = [ - 'AaaaRecord', 'ARecord', - 'AzureEntityResource', + 'AaaaRecord', 'CaaRecord', + 'CloudErrorBody', 'CnameRecord', 'MxRecord', 'NsRecord', - 'ProxyResource', 'PtrRecord', 'RecordSet', + 'RecordSetListResult', 'RecordSetUpdateParameters', 'Resource', 'SoaRecord', @@ -75,9 +73,8 @@ 'TrackedResource', 'TxtRecord', 'Zone', + 'ZoneListResult', 'ZoneUpdate', - 'RecordSetPaged', - 'ZonePaged', - 'ZoneType', 'RecordType', + 'ZoneType', ] 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 05db7027d336..f2abeece2155 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 @@ -1,32 +1,47 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) -class ZoneType(str, Enum): + 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) - public = "Public" - private = "Private" +class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class RecordType(str, Enum): + A = "A" + AAAA = "AAAA" + CAA = "CAA" + CNAME = "CNAME" + MX = "MX" + NS = "NS" + PTR = "PTR" + SOA = "SOA" + SRV = "SRV" + TXT = "TXT" - a = "A" - aaaa = "AAAA" - caa = "CAA" - cname = "CNAME" - mx = "MX" - ns = "NS" - ptr = "PTR" - soa = "SOA" - srv = "SRV" - txt = "TXT" +class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of this DNS zone (Public or Private). + """ + + PUBLIC = "Public" + PRIVATE = "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 index 57b66c8942a0..11d7260189db 100644 --- 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 @@ -1,19 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AaaaRecord(Model): +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +20,15 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = kwargs.get('ipv6_address', None) -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,89 +39,18 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = kwargs.get('ipv4_address', None) -class Resource(Model): - """Resource. - - 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. Ex- - 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 AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CaaRecord(Model): +class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and - 255. + :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 @@ -136,53 +64,30 @@ class CaaRecord(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + 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 CloudError(Model): - """An error message. - - :param error: The error message body - :type error: ~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """The body of an error message. +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - :param code: The error code + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: A description of what caused the error + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: The target resource of the error message + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: Extra error information - :type details: - list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] """ _attribute_map = { @@ -192,7 +97,10 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -200,7 +108,7 @@ def __init__(self, **kwargs): self.details = kwargs.get('details', None) -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -211,12 +119,15 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = kwargs.get('cname', None) -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -230,13 +141,16 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = kwargs.get('preference', None) self.exchange = kwargs.get('exchange', None) -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -247,45 +161,15 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = kwargs.get('nsdname', None) -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ProxyResource, self).__init__(**kwargs) - - -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -296,17 +180,18 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = kwargs.get('ptrdname', None) -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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. + 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 @@ -322,33 +207,26 @@ class RecordSet(Model): :type ttl: long :ivar fqdn: Fully qualified domain name of the record set. :vartype fqdn: str - :param arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] + :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] + :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] + :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] + :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] + :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] + :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] + :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] + :type caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] """ _validation = { @@ -366,7 +244,7 @@ class RecordSet(Model): 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, 'ttl': {'key': 'properties.TTL', 'type': 'long'}, 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -378,7 +256,10 @@ class RecordSet(Model): 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -387,7 +268,7 @@ def __init__(self, **kwargs): self.metadata = kwargs.get('metadata', None) self.ttl = kwargs.get('ttl', None) self.fqdn = None - self.arecords = kwargs.get('arecords', 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) @@ -399,11 +280,39 @@ def __init__(self, **kwargs): self.caa_records = kwargs.get('caa_records', None) -class RecordSetUpdateParameters(Model): +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. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet """ @@ -411,16 +320,55 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = kwargs.get('record_set', None) -class SoaRecord(Model): +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. + :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 @@ -432,8 +380,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -447,7 +395,10 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = kwargs.get('host', None) self.email = kwargs.get('email', None) @@ -458,7 +409,7 @@ def __init__(self, **kwargs): self.minimum_ttl = kwargs.get('minimum_ttl', None) -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -478,7 +429,10 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = kwargs.get('priority', None) self.weight = kwargs.get('weight', None) @@ -486,7 +440,7 @@ def __init__(self, **kwargs): self.target = kwargs.get('target', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """A reference to a another resource. :param id: Resource Id. @@ -497,30 +451,32 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level 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. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -539,13 +495,16 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -556,7 +515,10 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -564,50 +526,47 @@ def __init__(self, **kwargs): class Zone(TrackedResource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :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. + :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 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 + :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. + :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] + :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 = { @@ -616,6 +575,7 @@ class Zone(TrackedResource): '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}, } @@ -628,17 +588,22 @@ class Zone(TrackedResource): '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': 'ZoneType'}, + '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): + 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") @@ -646,10 +611,39 @@ def __init__(self, **kwargs): self.resolution_virtual_networks = kwargs.get('resolution_virtual_networks', None) -class ZoneUpdate(Model): +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: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -657,6 +651,9 @@ class ZoneUpdate(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + 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 4d8cf1ec41c4..8288d18b8b61 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 @@ -1,19 +1,19 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AaaaRecord(Model): +from ._dns_management_client_enums import * + + +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +24,17 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, *, ipv6_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv6_address: Optional[str] = None, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,89 +45,20 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, *, ipv4_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv4_address: Optional[str] = None, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address -class Resource(Model): - """Resource. - - 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. Ex- - 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) -> None: - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AzureEntityResource(Resource): - """The resource model definition for a Azure Resource Manager resource with an - etag. - - 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. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. - :vartype type: str - :ivar etag: Resource Etag. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(AzureEntityResource, self).__init__(**kwargs) - self.etag = None - - -class CaaRecord(Model): +class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and - 255. + :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 @@ -136,53 +72,34 @@ class CaaRecord(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, flags: int=None, tag: str=None, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + flags: Optional[int] = None, + tag: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): super(CaaRecord, self).__init__(**kwargs) self.flags = flags self.tag = tag self.value = value -class CloudError(Model): - """An error message. +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - :param error: The error message body - :type error: ~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """The body of an error message. - - :param code: The error code + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: A description of what caused the error + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: The target resource of the error message + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: Extra error information - :type details: - list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.dns.v2018_03_01_preview.models.CloudErrorBody] """ _attribute_map = { @@ -192,7 +109,15 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, *, code: str=None, message: str=None, target: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -200,7 +125,7 @@ def __init__(self, *, code: str=None, message: str=None, target: str=None, detai self.details = details -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -211,12 +136,17 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, *, cname: str=None, **kwargs) -> None: + def __init__( + self, + *, + cname: Optional[str] = None, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = cname -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -230,13 +160,19 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, *, preference: int=None, exchange: str=None, **kwargs) -> None: + def __init__( + self, + *, + preference: Optional[int] = None, + exchange: Optional[str] = None, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -247,45 +183,17 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, *, nsdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + nsdname: Optional[str] = None, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have - everything other than required location and tags. - - 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. Ex- - 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) -> None: - super(ProxyResource, self).__init__(**kwargs) - - -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -296,17 +204,20 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, *, ptrdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + ptrdname: Optional[str] = None, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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. + 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 @@ -322,33 +233,26 @@ class RecordSet(Model): :type ttl: long :ivar fqdn: Fully qualified domain name of the record set. :vartype fqdn: str - :param arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2018_03_01_preview.models.ARecord] + :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] + :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] + :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] + :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] + :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] + :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] + :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] + :type caa_records: list[~azure.mgmt.dns.v2018_03_01_preview.models.CaaRecord] """ _validation = { @@ -366,7 +270,7 @@ class RecordSet(Model): 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, 'ttl': {'key': 'properties.TTL', 'type': 'long'}, 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -378,7 +282,24 @@ class RecordSet(Model): 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, } - def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, arecords=None, aaaa_records=None, mx_records=None, ns_records=None, ptr_records=None, srv_records=None, txt_records=None, cname_record=None, soa_record=None, caa_records=None, **kwargs) -> None: + def __init__( + self, + *, + etag: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + ttl: Optional[int] = None, + a_records: Optional[List["ARecord"]] = None, + aaaa_records: Optional[List["AaaaRecord"]] = None, + mx_records: Optional[List["MxRecord"]] = None, + ns_records: Optional[List["NsRecord"]] = None, + ptr_records: Optional[List["PtrRecord"]] = None, + srv_records: Optional[List["SrvRecord"]] = None, + txt_records: Optional[List["TxtRecord"]] = None, + cname_record: Optional["CnameRecord"] = None, + soa_record: Optional["SoaRecord"] = None, + caa_records: Optional[List["CaaRecord"]] = None, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -387,7 +308,7 @@ def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, arecords=Non self.metadata = metadata self.ttl = ttl self.fqdn = None - self.arecords = arecords + self.a_records = a_records self.aaaa_records = aaaa_records self.mx_records = mx_records self.ns_records = ns_records @@ -399,11 +320,41 @@ def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, arecords=Non self.caa_records = caa_records -class RecordSetUpdateParameters(Model): +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, + *, + value: Optional[List["RecordSet"]] = None, + **kwargs + ): + super(RecordSetListResult, self).__init__(**kwargs) + self.value = value + 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. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet """ @@ -411,16 +362,57 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, *, record_set=None, **kwargs) -> None: + def __init__( + self, + *, + record_set: Optional["RecordSet"] = None, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set -class SoaRecord(Model): +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. + :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 @@ -432,8 +424,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -447,7 +439,18 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, refresh_time: int=None, retry_time: int=None, expire_time: int=None, minimum_ttl: int=None, **kwargs) -> None: + def __init__( + self, + *, + host: Optional[str] = None, + email: Optional[str] = None, + serial_number: Optional[int] = None, + refresh_time: Optional[int] = None, + retry_time: Optional[int] = None, + expire_time: Optional[int] = None, + minimum_ttl: Optional[int] = None, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -458,7 +461,7 @@ def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, self.minimum_ttl = minimum_ttl -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -478,7 +481,15 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, *, priority: int=None, weight: int=None, port: int=None, target: str=None, **kwargs) -> None: + def __init__( + self, + *, + priority: Optional[int] = None, + weight: Optional[int] = None, + port: Optional[int] = None, + target: Optional[str] = None, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -486,7 +497,7 @@ def __init__(self, *, priority: int=None, weight: int=None, port: int=None, targ self.target = target -class SubResource(Model): +class SubResource(msrest.serialization.Model): """A reference to a another resource. :param id: Resource Id. @@ -497,30 +508,34 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level 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. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :param location: Required. The geo-location where the resource lives. :type location: str """ @@ -539,13 +554,19 @@ class TrackedResource(Resource): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, *, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -556,7 +577,12 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List[str]] = None, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -564,50 +590,47 @@ def __init__(self, *, value=None, **kwargs) -> None: class Zone(TrackedResource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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} + :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 + :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- - Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives + :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. + :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 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 + :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. + :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] + :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 = { @@ -616,6 +639,7 @@ class Zone(TrackedResource): '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}, } @@ -628,17 +652,29 @@ class Zone(TrackedResource): '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': 'ZoneType'}, + '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, *, location: str, tags=None, etag: str=None, zone_type="Public", registration_virtual_networks=None, resolution_virtual_networks=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + zone_type: Optional[Union[str, "ZoneType"]] = "Public", + registration_virtual_networks: Optional[List["SubResource"]] = None, + resolution_virtual_networks: Optional[List["SubResource"]] = None, + **kwargs + ): super(Zone, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.max_number_of_record_sets = None + self.max_number_of_records_per_record_set = None self.number_of_record_sets = None self.name_servers = None self.zone_type = zone_type @@ -646,10 +682,41 @@ def __init__(self, *, location: str, tags=None, etag: str=None, zone_type="Publi self.resolution_virtual_networks = resolution_virtual_networks -class ZoneUpdate(Model): +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, + *, + value: Optional[List["Zone"]] = None, + **kwargs + ): + super(ZoneListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ZoneUpdate(msrest.serialization.Model): """Describes a request to update a DNS zone. - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -657,6 +724,11 @@ class ZoneUpdate(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, tags=None, **kwargs) -> None: + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ZoneUpdate, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_paged_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_paged_models.py deleted file mode 100644 index e441cabf4f5f..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/models/_paged_models.py +++ /dev/null @@ -1,40 +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. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class RecordSetPaged(Paged): - """ - A paging container for iterating over a list of :class:`RecordSet ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RecordSet]'} - } - - def __init__(self, *args, **kwargs): - - super(RecordSetPaged, self).__init__(*args, **kwargs) -class ZonePaged(Paged): - """ - A paging container for iterating over a list of :class:`Zone ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Zone]'} - } - - def __init__(self, *args, **kwargs): - - super(ZonePaged, self).__init__(*args, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/__init__.py index cc23646a5b90..caab83d882c4 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._record_sets_operations import RecordSetsOperations 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 da42f611ec3c..b23b481345cb 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,629 +1,628 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat -from .. import models +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]] class RecordSetsOperations(object): """RecordSetsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_03_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-03-01-preview". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-03-01-preview" - - self.config = config + self._config = config def update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + 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" """Updates a record set within a DNS zone. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', - 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType :param parameters: Parameters supplied to the Update operation. :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def create_or_update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): + 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" """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA can be updated but not created (they are created when - the DNS zone is created). Possible values include: 'A', 'AAAA', 'CAA', - 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def delete( - self, resource_group_name, zone_name, relative_record_set_name, record_type, if_match=None, custom_headers=None, raw=False, **operation_config): + 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 """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA cannot be deleted (they are deleted when the DNS zone - is deleted). Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', - 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :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. + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def get( - self, resource_group_name, zone_name, relative_record_set_name, record_type, custom_headers=None, raw=False, **operation_config): + 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" """Gets a record set. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', - 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type record_type: str or ~azure.mgmt.dns.v2018_03_01_preview.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.get.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def list_by_type( - self, resource_group_name, zone_name, record_type, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param record_type: The type of record sets to enumerate. Possible - values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', - 'SRV', 'TXT' - :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. + :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. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] - :raises: :class:`CloudError` + :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] + :raises: ~azure.core.exceptions.HttpResponseError """ + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} + return ItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore def list_by_dns_zone( - self, resource_group_name, zone_name, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists all record sets in a DNS zone. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] - :raises: :class:`CloudError` + :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] + :raises: ~azure.core.exceptions.HttpResponseError """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} + return ItemPaged( + get_next, extract_data + ) + list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore def list_all_by_dns_zone( - self, resource_group_name, zone_name, top=None, record_set_name_suffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists all record sets in a DNS zone. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :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 . + :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:``. :type record_set_name_suffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_03_01_preview.models.RecordSetPaged[~azure.mgmt.dns.v2018_03_01_preview.models.RecordSet] - :raises: :class:`CloudError` + :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] + :raises: ~azure.core.exceptions.HttpResponseError """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} + 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 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 ff2cdeff0bc2..773b93dadd92 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,503 +1,534 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +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]] class ZonesOperations(object): """ZonesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_03_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-03-01-preview". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-03-01-preview" - - self.config = config + self._config = config def create_or_update( - self, resource_group_name, zone_name, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): - """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. + 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" + """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. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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'] + 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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'Zone') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def _delete_initial( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + zone_name, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> 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.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a DNS zone. WARNING: All DNS records in the zone will also be - deleted. This operation cannot be undone. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + zone_name, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - zone_name=zone_name, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + 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, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + 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), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def get( - self, resource_group_name, zone_name, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + zone_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.get.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def update( - self, resource_group_name, zone_name, if_match=None, tags=None, custom_headers=None, raw=False, **operation_config): + 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" """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. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :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. + :param parameters: Parameters supplied to the Update operation. + :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. :type if_match: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_03_01_preview.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ZoneUpdate(tags=tags) + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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'] + 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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ZoneUpdate') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2018_03_01_preview.models.ZonePaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore def list( - self, top=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 + zones. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2018_03_01_preview.models.ZonePaged[~azure.mgmt.dns.v2018_03_01_preview.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + 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) + '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 = {} + 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("self.api_version", self.api_version, 'str', min_length=1) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} + return ItemPaged( + get_next, extract_data + ) + 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/py.typed b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_03_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/__init__.py index e492c24b0aaf..34fbcbfae313 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 @@ -1,19 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DnsManagementClientConfiguration from ._dns_management_client import DnsManagementClient -__all__ = ['DnsManagementClient', 'DnsManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['DnsManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 5f82572692d1..425269cc68d0 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 @@ -1,49 +1,70 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. -class DnsManagementClientConfiguration(AzureConfiguration): - """Configuration for DnsManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Specifies the Azure subscription ID, which - uniquely identifies the Microsoft Azure subscription. + :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. :type subscription_id: str - :param str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(DnsManagementClientConfiguration, self).__init__(**kwargs) - super(DnsManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-dns/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-05-01" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(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 7060bfa04bb7..84eb7937d397 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 @@ -1,16 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import 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 ._configuration import DnsManagementClientConfiguration from .operations import RecordSetsOperations @@ -19,42 +24,57 @@ from . import models -class DnsManagementClient(SDKClient): +class DnsManagementClient(object): """The DNS Management Client. - :ivar config: Configuration for client. - :vartype config: DnsManagementClientConfiguration - - :ivar record_sets: RecordSets operations + :ivar record_sets: RecordSetsOperations operations :vartype record_sets: azure.mgmt.dns.v2018_05_01.operations.RecordSetsOperations - :ivar zones: Zones operations + :ivar zones: ZonesOperations operations :vartype zones: azure.mgmt.dns.v2018_05_01.operations.ZonesOperations - :ivar dns_resource_reference: DnsResourceReference operations + :ivar dns_resource_reference: DnsResourceReferenceOperations operations :vartype dns_resource_reference: azure.mgmt.dns.v2018_05_01.operations.DnsResourceReferenceOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Specifies the Azure subscription ID, which - uniquely identifies the Microsoft Azure subscription. + :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. :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = DnsManagementClientConfiguration(credentials, subscription_id, base_url) - super(DnsManagementClient, self).__init__(self.config.credentials, self.config) + 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) + 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.api_version = '2018-05-01' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.record_sets = RecordSetsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.zones = ZonesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.dns_resource_reference = DnsResourceReferenceOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DnsManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f81bc6c1e4b --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/_metadata.json @@ -0,0 +1,63 @@ +{ + "chosen_version": "2018-05-01", + "total_api_version_list": ["2018-05-01"], + "client": { + "name": "DnsManagementClient", + "filename": "_dns_management_client", + "description": "The DNS Management Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "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 + }, + "operation_groups": { + "record_sets": "RecordSetsOperations", + "zones": "ZonesOperations", + "dns_resource_reference": "DnsResourceReferenceOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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 new file mode 100644 index 000000000000..1a93fabcef86 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dns_management_client import DnsManagementClient +__all__ = ['DnsManagementClient'] 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 new file mode 100644 index 000000000000..c7393ce84be3 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class DnsManagementClientConfiguration(Configuration): + """Configuration for DnsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dns/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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 new file mode 100644 index 000000000000..f4a84435efdc --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/_dns_management_client.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +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 ._configuration import DnsManagementClientConfiguration +from .operations import RecordSetsOperations +from .operations import ZonesOperations +from .operations import DnsResourceReferenceOperations +from .. import models + + +class DnsManagementClient(object): + """The DNS Management Client. + + :ivar record_sets: RecordSetsOperations operations + :vartype record_sets: azure.mgmt.dns.v2018_05_01.aio.operations.RecordSetsOperations + :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 + :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. + :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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + 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.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DnsManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/__init__.py new file mode 100644 index 000000000000..1b7483b4a71f --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._record_sets_operations import RecordSetsOperations +from ._zones_operations import ZonesOperations +from ._dns_resource_reference_operations import DnsResourceReferenceOperations + +__all__ = [ + 'RecordSetsOperations', + 'ZonesOperations', + 'DnsResourceReferenceOperations', +] 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 new file mode 100644 index 000000000000..a254031feeff --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_dns_resource_reference_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DnsResourceReferenceOperations: + """DnsResourceReferenceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_by_target_resources( + self, + parameters: "_models.DnsResourceReferenceRequest", + **kwargs + ) -> "_models.DnsResourceReferenceResult": + """Returns the DNS records specified by the referencing targetResourceIds. + + :param parameters: Properties for dns resource reference request. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DnsResourceReferenceResult, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResourceReferenceResult"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DnsResourceReferenceResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_target_resources.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference'} # 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 new file mode 100644 index 000000000000..1f22824ea0b6 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_record_sets_operations.py @@ -0,0 +1,617 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RecordSetsOperations: + """RecordSetsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + **kwargs + ) -> "_models.RecordSet": + """Updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType + :param parameters: Parameters supplied to the Update operation. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + parameters: "_models.RecordSet", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_models.RecordSet": + """Creates or updates a record set within a DNS zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def delete( + 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 + ) -> None: + """Deletes a record set from a DNS zone. This operation cannot be undone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + relative_record_set_name: str, + record_type: Union[str, "_models.RecordType"], + **kwargs + ) -> "_models.RecordSet": + """Gets a record set. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param relative_record_set_name: The name of the record set, relative to the name of the zone. + :type relative_record_set_name: str + :param record_type: The type of DNS record in this record set. + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.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') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecordSet', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore + + def list_by_type( + self, + resource_group_name: str, + zone_name: str, + record_type: Union[str, "_models.RecordType"], + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_models.RecordSetListResult"]: + """Lists the record sets of a specified type in a DNS zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore + + def list_by_dns_zone( + self, + resource_group_name: str, + zone_name: str, + top: Optional[int] = None, + recordsetnamesuffix: Optional[str] = None, + **kwargs + ) -> AsyncIterable["_models.RecordSetListResult"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore + + 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 + ) -> AsyncIterable["_models.RecordSetListResult"]: + """Lists all record sets in a DNS zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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. + :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:``. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_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 new file mode 100644 index 000000000000..c91434a193f2 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/aio/operations/_zones_operations.py @@ -0,0 +1,523 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ZonesOperations: + """ZonesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + resource_group_name: str, + zone_name: str, + parameters: "_models.Zone", + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param parameters: Parameters supplied to the CreateOrUpdate operation. + :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. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Zone', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 + ) -> 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') + + # 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + zone_name: str, + if_match: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + 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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + zone_name: str, + **kwargs + ) -> "_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. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + zone_name: str, + parameters: "_models.ZoneUpdate", + if_match: Optional[str] = None, + **kwargs + ) -> "_models.Zone": + """Updates a DNS zone. Does not modify DNS records within the zone. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param zone_name: The name of the DNS zone (without a terminating dot). + :type zone_name: str + :param parameters: Parameters supplied to the Update operation. + :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. + :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) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Zone', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore + + def list( + self, + top: Optional[int] = None, + **kwargs + ) -> 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. + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/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 c9f029f18777..ecceb3cb0c3b 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 @@ -1,18 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AaaaRecord 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 @@ -21,6 +19,7 @@ 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 @@ -28,38 +27,42 @@ 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 AaaaRecord - from ._models import ARecord - from ._models import CaaRecord - from ._models import CnameRecord - from ._models import DnsResourceReference - from ._models import DnsResourceReferenceRequest - from ._models import DnsResourceReferenceResult - from ._models import MxRecord - from ._models import NsRecord - from ._models import PtrRecord - from ._models import RecordSet - from ._models import RecordSetUpdateParameters - from ._models import Resource - from ._models import SoaRecord - from ._models import SrvRecord - from ._models import SubResource - from ._models import TxtRecord - from ._models import Zone - from ._models import ZoneUpdate -from ._paged_models import RecordSetPaged -from ._paged_models import ZonePaged + 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 ._dns_management_client_enums import ( - ZoneType, RecordType, + ZoneType, ) __all__ = [ - 'AaaaRecord', 'ARecord', + 'AaaaRecord', 'CaaRecord', + 'CloudErrorBody', 'CnameRecord', 'DnsResourceReference', 'DnsResourceReferenceRequest', @@ -68,6 +71,7 @@ 'NsRecord', 'PtrRecord', 'RecordSet', + 'RecordSetListResult', 'RecordSetUpdateParameters', 'Resource', 'SoaRecord', @@ -75,9 +79,8 @@ 'SubResource', 'TxtRecord', 'Zone', + 'ZoneListResult', 'ZoneUpdate', - 'RecordSetPaged', - 'ZonePaged', - 'ZoneType', 'RecordType', + 'ZoneType', ] 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 05db7027d336..f2abeece2155 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 @@ -1,32 +1,47 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) -class ZoneType(str, Enum): + 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) - public = "Public" - private = "Private" +class RecordType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class RecordType(str, Enum): + A = "A" + AAAA = "AAAA" + CAA = "CAA" + CNAME = "CNAME" + MX = "MX" + NS = "NS" + PTR = "PTR" + SOA = "SOA" + SRV = "SRV" + TXT = "TXT" - a = "A" - aaaa = "AAAA" - caa = "CAA" - cname = "CNAME" - mx = "MX" - ns = "NS" - ptr = "PTR" - soa = "SOA" - srv = "SRV" - txt = "TXT" +class ZoneType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of this DNS zone (Public or Private). + """ + + PUBLIC = "Public" + PRIVATE = "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 index 64e18daa3bed..eec9fa62b048 100644 --- 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 @@ -1,19 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AaaaRecord(Model): +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +20,15 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = kwargs.get('ipv6_address', None) -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,16 +39,18 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = kwargs.get('ipv4_address', None) -class CaaRecord(Model): +class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and - 255. + :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 @@ -63,51 +64,29 @@ class CaaRecord(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + 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 CloudError(Model): - """An error message. +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - :param error: The error message body - :type error: ~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """The body of an error message. - - :param code: The error code + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: A description of what caused the error + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: The target resource of the error message + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: Extra error information + :param details: A list of additional details about the error. :type details: list[~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody] """ @@ -118,7 +97,10 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -126,7 +108,7 @@ def __init__(self, **kwargs): self.details = kwargs.get('details', None) -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -137,18 +119,21 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = kwargs.get('cname', None) -class DnsResourceReference(Model): +class DnsResourceReference(msrest.serialization.Model): """Represents a single Azure resource and its referencing DNS records. - :param dns_resources: A list of 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. + :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 """ @@ -157,50 +142,56 @@ class DnsResourceReference(Model): 'target_resource': {'key': 'targetResource', 'type': 'SubResource'}, } - def __init__(self, **kwargs): + 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(Model): +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] + :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): + def __init__( + self, + **kwargs + ): super(DnsResourceReferenceRequest, self).__init__(**kwargs) self.target_resources = kwargs.get('target_resources', None) -class DnsResourceReferenceResult(Model): +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] + :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): + def __init__( + self, + **kwargs + ): super(DnsResourceReferenceResult, self).__init__(**kwargs) self.dns_resource_references = kwargs.get('dns_resource_references', None) -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -214,13 +205,16 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = kwargs.get('preference', None) self.exchange = kwargs.get('exchange', None) -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -231,12 +225,15 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = kwargs.get('nsdname', None) -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -247,17 +244,18 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = kwargs.get('ptrdname', None) -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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. + 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 @@ -275,11 +273,11 @@ class RecordSet(Model): :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. + :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 arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] + :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. @@ -318,7 +316,7 @@ class RecordSet(Model): 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'target_resource': {'key': 'properties.targetResource', 'type': 'SubResource'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -330,7 +328,10 @@ class RecordSet(Model): 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -341,7 +342,7 @@ def __init__(self, **kwargs): self.fqdn = None self.provisioning_state = None self.target_resource = kwargs.get('target_resource', None) - self.arecords = kwargs.get('arecords', 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) @@ -353,11 +354,39 @@ def __init__(self, **kwargs): self.caa_records = kwargs.get('caa_records', None) -class RecordSetUpdateParameters(Model): +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. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet """ @@ -365,16 +394,18 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = kwargs.get('record_set', None) -class Resource(Model): +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. + 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. @@ -386,7 +417,7 @@ class Resource(Model): :vartype type: str :param location: Required. Resource location. :type location: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -405,20 +436,22 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) -class SoaRecord(Model): +class SoaRecord(msrest.serialization.Model): """An SOA record. - :param host: The domain name of the authoritative name server for this 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 @@ -430,8 +463,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -445,7 +478,10 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = kwargs.get('host', None) self.email = kwargs.get('email', None) @@ -456,7 +492,7 @@ def __init__(self, **kwargs): self.minimum_ttl = kwargs.get('minimum_ttl', None) -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -476,7 +512,10 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = kwargs.get('priority', None) self.weight = kwargs.get('weight', None) @@ -484,7 +523,7 @@ def __init__(self, **kwargs): self.target = kwargs.get('target', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """A reference to a another resource. :param id: Resource Id. @@ -495,12 +534,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -511,7 +553,10 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -519,8 +564,7 @@ def __init__(self, **kwargs): class Zone(Resource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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. @@ -532,34 +576,32 @@ class Zone(Resource): :vartype type: str :param location: Required. Resource location. :type location: str - :param tags: Resource tags. + :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. + :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 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 + :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" . + :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] + :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 = { @@ -568,6 +610,7 @@ class Zone(Resource): '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}, } @@ -580,17 +623,22 @@ class Zone(Resource): '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': 'ZoneType'}, + '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): + 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") @@ -598,10 +646,39 @@ def __init__(self, **kwargs): self.resolution_virtual_networks = kwargs.get('resolution_virtual_networks', None) -class ZoneUpdate(Model): +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: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -609,6 +686,9 @@ class ZoneUpdate(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + 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 6f0bcac5818b..c6c2406e6a63 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 @@ -1,19 +1,19 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AaaaRecord(Model): +from ._dns_management_client_enums import * + + +class AaaaRecord(msrest.serialization.Model): """An AAAA record. :param ipv6_address: The IPv6 address of this AAAA record. @@ -24,12 +24,17 @@ class AaaaRecord(Model): 'ipv6_address': {'key': 'ipv6Address', 'type': 'str'}, } - def __init__(self, *, ipv6_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv6_address: Optional[str] = None, + **kwargs + ): super(AaaaRecord, self).__init__(**kwargs) self.ipv6_address = ipv6_address -class ARecord(Model): +class ARecord(msrest.serialization.Model): """An A record. :param ipv4_address: The IPv4 address of this A record. @@ -40,16 +45,20 @@ class ARecord(Model): 'ipv4_address': {'key': 'ipv4Address', 'type': 'str'}, } - def __init__(self, *, ipv4_address: str=None, **kwargs) -> None: + def __init__( + self, + *, + ipv4_address: Optional[str] = None, + **kwargs + ): super(ARecord, self).__init__(**kwargs) self.ipv4_address = ipv4_address -class CaaRecord(Model): +class CaaRecord(msrest.serialization.Model): """A CAA record. - :param flags: The flags for this CAA record as an integer between 0 and - 255. + :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 @@ -63,51 +72,33 @@ class CaaRecord(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, flags: int=None, tag: str=None, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + flags: Optional[int] = None, + tag: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): super(CaaRecord, self).__init__(**kwargs) self.flags = flags self.tag = tag self.value = value -class CloudError(Model): - """An error message. - - :param error: The error message body - :type error: ~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class CloudErrorBody(Model): - """The body of an error message. - - :param code: The error code + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. :type code: str - :param message: A description of what caused the error + :param message: A message describing the error, intended to be suitable for display in a user + interface. :type message: str - :param target: The target resource of the error message + :param target: The target of the particular error. For example, the name of the property in + error. :type target: str - :param details: Extra error information + :param details: A list of additional details about the error. :type details: list[~azure.mgmt.dns.v2018_05_01.models.CloudErrorBody] """ @@ -118,7 +109,15 @@ class CloudErrorBody(Model): 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, } - def __init__(self, *, code: str=None, message: str=None, target: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -126,7 +125,7 @@ def __init__(self, *, code: str=None, message: str=None, target: str=None, detai self.details = details -class CnameRecord(Model): +class CnameRecord(msrest.serialization.Model): """A CNAME record. :param cname: The canonical name for this CNAME record. @@ -137,18 +136,23 @@ class CnameRecord(Model): 'cname': {'key': 'cname', 'type': 'str'}, } - def __init__(self, *, cname: str=None, **kwargs) -> None: + def __init__( + self, + *, + cname: Optional[str] = None, + **kwargs + ): super(CnameRecord, self).__init__(**kwargs) self.cname = cname -class DnsResourceReference(Model): +class DnsResourceReference(msrest.serialization.Model): """Represents a single Azure resource and its referencing DNS records. - :param dns_resources: A list of 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. + :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 """ @@ -157,50 +161,63 @@ class DnsResourceReference(Model): 'target_resource': {'key': 'targetResource', 'type': 'SubResource'}, } - def __init__(self, *, dns_resources=None, target_resource=None, **kwargs) -> None: + def __init__( + self, + *, + dns_resources: Optional[List["SubResource"]] = None, + target_resource: Optional["SubResource"] = None, + **kwargs + ): super(DnsResourceReference, self).__init__(**kwargs) self.dns_resources = dns_resources self.target_resource = target_resource -class DnsResourceReferenceRequest(Model): +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] + :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, *, target_resources=None, **kwargs) -> None: + def __init__( + self, + *, + target_resources: Optional[List["SubResource"]] = None, + **kwargs + ): super(DnsResourceReferenceRequest, self).__init__(**kwargs) self.target_resources = target_resources -class DnsResourceReferenceResult(Model): +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] + :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, *, dns_resource_references=None, **kwargs) -> None: + def __init__( + self, + *, + dns_resource_references: Optional[List["DnsResourceReference"]] = None, + **kwargs + ): super(DnsResourceReferenceResult, self).__init__(**kwargs) self.dns_resource_references = dns_resource_references -class MxRecord(Model): +class MxRecord(msrest.serialization.Model): """An MX record. :param preference: The preference value for this MX record. @@ -214,13 +231,19 @@ class MxRecord(Model): 'exchange': {'key': 'exchange', 'type': 'str'}, } - def __init__(self, *, preference: int=None, exchange: str=None, **kwargs) -> None: + def __init__( + self, + *, + preference: Optional[int] = None, + exchange: Optional[str] = None, + **kwargs + ): super(MxRecord, self).__init__(**kwargs) self.preference = preference self.exchange = exchange -class NsRecord(Model): +class NsRecord(msrest.serialization.Model): """An NS record. :param nsdname: The name server name for this NS record. @@ -231,12 +254,17 @@ class NsRecord(Model): 'nsdname': {'key': 'nsdname', 'type': 'str'}, } - def __init__(self, *, nsdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + nsdname: Optional[str] = None, + **kwargs + ): super(NsRecord, self).__init__(**kwargs) self.nsdname = nsdname -class PtrRecord(Model): +class PtrRecord(msrest.serialization.Model): """A PTR record. :param ptrdname: The PTR target domain name for this PTR record. @@ -247,17 +275,20 @@ class PtrRecord(Model): 'ptrdname': {'key': 'ptrdname', 'type': 'str'}, } - def __init__(self, *, ptrdname: str=None, **kwargs) -> None: + def __init__( + self, + *, + ptrdname: Optional[str] = None, + **kwargs + ): super(PtrRecord, self).__init__(**kwargs) self.ptrdname = ptrdname -class RecordSet(Model): - """Describes a DNS record set (a collection of DNS records with the same name - and type). +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. + 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 @@ -275,11 +306,11 @@ class RecordSet(Model): :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. + :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 arecords: The list of A records in the record set. - :type arecords: list[~azure.mgmt.dns.v2018_05_01.models.ARecord] + :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. @@ -318,7 +349,7 @@ class RecordSet(Model): 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'target_resource': {'key': 'properties.targetResource', 'type': 'SubResource'}, - 'arecords': {'key': 'properties.ARecords', 'type': '[ARecord]'}, + '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]'}, @@ -330,7 +361,25 @@ class RecordSet(Model): 'caa_records': {'key': 'properties.caaRecords', 'type': '[CaaRecord]'}, } - def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, target_resource=None, arecords=None, aaaa_records=None, mx_records=None, ns_records=None, ptr_records=None, srv_records=None, txt_records=None, cname_record=None, soa_record=None, caa_records=None, **kwargs) -> None: + def __init__( + self, + *, + etag: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + ttl: Optional[int] = None, + target_resource: Optional["SubResource"] = None, + a_records: Optional[List["ARecord"]] = None, + aaaa_records: Optional[List["AaaaRecord"]] = None, + mx_records: Optional[List["MxRecord"]] = None, + ns_records: Optional[List["NsRecord"]] = None, + ptr_records: Optional[List["PtrRecord"]] = None, + srv_records: Optional[List["SrvRecord"]] = None, + txt_records: Optional[List["TxtRecord"]] = None, + cname_record: Optional["CnameRecord"] = None, + soa_record: Optional["SoaRecord"] = None, + caa_records: Optional[List["CaaRecord"]] = None, + **kwargs + ): super(RecordSet, self).__init__(**kwargs) self.id = None self.name = None @@ -341,7 +390,7 @@ def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, target_resou self.fqdn = None self.provisioning_state = None self.target_resource = target_resource - self.arecords = arecords + self.a_records = a_records self.aaaa_records = aaaa_records self.mx_records = mx_records self.ns_records = ns_records @@ -353,11 +402,41 @@ def __init__(self, *, etag: str=None, metadata=None, ttl: int=None, target_resou self.caa_records = caa_records -class RecordSetUpdateParameters(Model): +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, + *, + value: Optional[List["RecordSet"]] = None, + **kwargs + ): + super(RecordSetListResult, self).__init__(**kwargs) + self.value = value + 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. + :param record_set: Specifies information about the record set being updated. :type record_set: ~azure.mgmt.dns.v2018_05_01.models.RecordSet """ @@ -365,16 +444,20 @@ class RecordSetUpdateParameters(Model): 'record_set': {'key': 'RecordSet', 'type': 'RecordSet'}, } - def __init__(self, *, record_set=None, **kwargs) -> None: + def __init__( + self, + *, + record_set: Optional["RecordSet"] = None, + **kwargs + ): super(RecordSetUpdateParameters, self).__init__(**kwargs) self.record_set = record_set -class Resource(Model): +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. + 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. @@ -386,7 +469,7 @@ class Resource(Model): :vartype type: str :param location: Required. Resource location. :type location: str - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -405,7 +488,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -414,11 +503,10 @@ def __init__(self, *, location: str, tags=None, **kwargs) -> None: self.tags = tags -class SoaRecord(Model): +class SoaRecord(msrest.serialization.Model): """An SOA record. - :param host: The domain name of the authoritative name server for this 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 @@ -430,8 +518,8 @@ class SoaRecord(Model): :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. + :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 """ @@ -445,7 +533,18 @@ class SoaRecord(Model): 'minimum_ttl': {'key': 'minimumTTL', 'type': 'long'}, } - def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, refresh_time: int=None, retry_time: int=None, expire_time: int=None, minimum_ttl: int=None, **kwargs) -> None: + def __init__( + self, + *, + host: Optional[str] = None, + email: Optional[str] = None, + serial_number: Optional[int] = None, + refresh_time: Optional[int] = None, + retry_time: Optional[int] = None, + expire_time: Optional[int] = None, + minimum_ttl: Optional[int] = None, + **kwargs + ): super(SoaRecord, self).__init__(**kwargs) self.host = host self.email = email @@ -456,7 +555,7 @@ def __init__(self, *, host: str=None, email: str=None, serial_number: int=None, self.minimum_ttl = minimum_ttl -class SrvRecord(Model): +class SrvRecord(msrest.serialization.Model): """An SRV record. :param priority: The priority value for this SRV record. @@ -476,7 +575,15 @@ class SrvRecord(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, *, priority: int=None, weight: int=None, port: int=None, target: str=None, **kwargs) -> None: + def __init__( + self, + *, + priority: Optional[int] = None, + weight: Optional[int] = None, + port: Optional[int] = None, + target: Optional[str] = None, + **kwargs + ): super(SrvRecord, self).__init__(**kwargs) self.priority = priority self.weight = weight @@ -484,7 +591,7 @@ def __init__(self, *, priority: int=None, weight: int=None, port: int=None, targ self.target = target -class SubResource(Model): +class SubResource(msrest.serialization.Model): """A reference to a another resource. :param id: Resource Id. @@ -495,12 +602,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TxtRecord(Model): +class TxtRecord(msrest.serialization.Model): """A TXT record. :param value: The text value of this TXT record. @@ -511,7 +623,12 @@ class TxtRecord(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List[str]] = None, + **kwargs + ): super(TxtRecord, self).__init__(**kwargs) self.value = value @@ -519,8 +636,7 @@ def __init__(self, *, value=None, **kwargs) -> None: class Zone(Resource): """Describes a DNS zone. - Variables are only populated by the server, and will be ignored when - sending a request. + 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. @@ -532,34 +648,32 @@ class Zone(Resource): :vartype type: str :param location: Required. Resource location. :type location: str - :param tags: Resource tags. + :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. + :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 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 + :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" . + :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] + :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 = { @@ -568,6 +682,7 @@ class Zone(Resource): '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}, } @@ -580,17 +695,29 @@ class Zone(Resource): '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': 'ZoneType'}, + '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, *, location: str, tags=None, etag: str=None, zone_type="Public", registration_virtual_networks=None, resolution_virtual_networks=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + zone_type: Optional[Union[str, "ZoneType"]] = "Public", + registration_virtual_networks: Optional[List["SubResource"]] = None, + resolution_virtual_networks: Optional[List["SubResource"]] = None, + **kwargs + ): super(Zone, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.max_number_of_record_sets = None + self.max_number_of_records_per_record_set = None self.number_of_record_sets = None self.name_servers = None self.zone_type = zone_type @@ -598,10 +725,41 @@ def __init__(self, *, location: str, tags=None, etag: str=None, zone_type="Publi self.resolution_virtual_networks = resolution_virtual_networks -class ZoneUpdate(Model): +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, + *, + value: Optional[List["Zone"]] = None, + **kwargs + ): + super(ZoneListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ZoneUpdate(msrest.serialization.Model): """Describes a request to update a DNS zone. - :param tags: Resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -609,6 +767,11 @@ class ZoneUpdate(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, tags=None, **kwargs) -> None: + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ZoneUpdate, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_paged_models.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_paged_models.py deleted file mode 100644 index 75e9d5910501..000000000000 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/models/_paged_models.py +++ /dev/null @@ -1,40 +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. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class RecordSetPaged(Paged): - """ - A paging container for iterating over a list of :class:`RecordSet ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RecordSet]'} - } - - def __init__(self, *args, **kwargs): - - super(RecordSetPaged, self).__init__(*args, **kwargs) -class ZonePaged(Paged): - """ - A paging container for iterating over a list of :class:`Zone ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Zone]'} - } - - def __init__(self, *args, **kwargs): - - super(ZonePaged, self).__init__(*args, **kwargs) diff --git a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/__init__.py b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/__init__.py index 3f16069d2d3f..1b7483b4a71f 100644 --- a/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/__init__.py +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._record_sets_operations import RecordSetsOperations 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 5fb9d919932b..a69e3bd8f53d 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,105 +1,104 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat -from .. import models +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]] class DnsResourceReferenceOperations(object): """DnsResourceReferenceOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Specifies the API version. Constant value: "2018-05-01". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def get_by_target_resources( - self, target_resources=None, custom_headers=None, raw=False, **operation_config): + self, + parameters, # type: "_models.DnsResourceReferenceRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.DnsResourceReferenceResult" """Returns the DNS records specified by the referencing targetResourceIds. - :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] - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DnsResourceReferenceResult or ClientRawResponse if raw=true + :param parameters: Properties for dns resource reference request. + :type parameters: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DnsResourceReferenceResult, or the result of cls(response) :rtype: ~azure.mgmt.dns.v2018_05_01.models.DnsResourceReferenceResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.DnsResourceReferenceRequest(target_resources=target_resources) + cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResourceReferenceResult"] + error_map = { + 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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DnsResourceReferenceRequest') + 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') - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DnsResourceReferenceResult', response) + deserialized = self._deserialize('DnsResourceReferenceResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_target_resources.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/getDnsResourceReference'} + 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 85554bcbbbd7..7c9b6ec708a0 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,622 +1,628 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat -from .. import models +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]] class RecordSetsOperations(object): """RecordSetsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Specifies the API version. Constant value: "2018-05-01". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + 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" """Updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', - 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_05_01.models.RecordType + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType :param parameters: Parameters supplied to the Update operation. :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def create_or_update( - self, resource_group_name, zone_name, relative_record_set_name, record_type, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): + 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" """Creates or updates a record set within a DNS zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA can be updated but not created (they are created when - the DNS zone is created). Possible values include: 'A', 'AAAA', 'CAA', - 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_05_01.models.RecordType - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param record_type: The type of DNS record in this record set. Record sets of type SOA can be + updated but not created (they are created when the DNS zone is created). + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + error_map = { + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'RecordSet') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def delete( - self, resource_group_name, zone_name, relative_record_set_name, record_type, if_match=None, custom_headers=None, raw=False, **operation_config): + 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 """Deletes a record set from a DNS zone. This operation cannot be undone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str - :param record_type: The type of DNS record in this record set. Record - sets of type SOA cannot be deleted (they are deleted when the DNS zone - is deleted). Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', - 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' - :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. + :param record_type: The type of DNS record in this record set. Record sets of type SOA cannot + be deleted (they are deleted when the DNS zone is deleted). + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + # Construct URL - url = self.delete.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def get( - self, resource_group_name, zone_name, relative_record_set_name, record_type, custom_headers=None, raw=False, **operation_config): + 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" """Gets a record set. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param relative_record_set_name: The name of the record set, relative - to the name of the zone. + :param relative_record_set_name: The name of the record set, relative to the name of the zone. :type relative_record_set_name: str :param record_type: The type of DNS record in this record set. - Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', - 'PTR', 'SOA', 'SRV', 'TXT' - :type record_type: str or - ~azure.mgmt.dns.v2018_05_01.models.RecordType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecordSet or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type record_type: str or ~azure.mgmt.dns.v2018_05_01.models.RecordType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecordSet, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.RecordSet + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RecordSet"] + 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.get.metadata['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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecordSet', response) + deserialized = self._deserialize('RecordSet', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}'} # type: ignore def list_by_type( - self, resource_group_name, zone_name, record_type, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists the record sets of a specified type in a DNS zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param record_type: The type of record sets to enumerate. Possible - values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', - 'SRV', 'TXT' - :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. + :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. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_05_01.models.RecordSetPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] - :raises: :class:`CloudError` + :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 """ + 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'] + 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, 'RecordType'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} + return ItemPaged( + get_next, extract_data + ) + list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}'} # type: ignore def list_by_dns_zone( - self, resource_group_name, zone_name, top=None, recordsetnamesuffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :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 . + :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:``. :type recordsetnamesuffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_05_01.models.RecordSetPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] - :raises: :class:`CloudError` + :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 """ + 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'] + 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') + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} + return ItemPaged( + get_next, extract_data + ) + list_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/recordsets'} # type: ignore def list_all_by_dns_zone( - self, resource_group_name, zone_name, top=None, record_set_name_suffix=None, custom_headers=None, raw=False, **operation_config): + 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"] """Lists all record sets in a DNS zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :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 . + :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:``. :type record_set_name_suffix: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RecordSet - :rtype: - ~azure.mgmt.dns.v2018_05_01.models.RecordSetPaged[~azure.mgmt.dns.v2018_05_01.models.RecordSet] - :raises: :class:`CloudError` + :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 """ + 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'] + 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') + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RecordSetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RecordSetPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_all_by_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/all'} + 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 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 8423bae31312..e4edd91a912a 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,498 +1,534 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +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]] class ZonesOperations(object): """ZonesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.dns.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Specifies the API version. Constant value: "2018-05-01". """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def create_or_update( - self, resource_group_name, zone_name, parameters, if_match=None, if_none_match=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates a DNS zone. Does not modify DNS records within the - zone. + 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" + """Creates or updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param parameters: Parameters supplied to the CreateOrUpdate - operation. + :param parameters: Parameters supplied to the CreateOrUpdate operation. :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. + :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. :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. + :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. :type if_none_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'Zone') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def _delete_initial( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + zone_name, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> 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.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore - def delete( - self, resource_group_name, zone_name, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a DNS zone. WARNING: All DNS records in the zone will also be - deleted. This operation cannot be undone. + def begin_delete( + self, + resource_group_name, # type: str + zone_name, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation + cannot be undone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - zone_name=zone_name, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + zone_name=zone_name, + if_match=if_match, + 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, {}) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + 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'), + } - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def get( - self, resource_group_name, zone_name, custom_headers=None, raw=False, **operation_config): - """Gets a DNS zone. Retrieves the zone properties, but not the record sets - within the zone. + self, + resource_group_name, # type: str + zone_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + 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.get.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def update( - self, resource_group_name, zone_name, if_match=None, tags=None, custom_headers=None, raw=False, **operation_config): + 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" """Updates a DNS zone. Does not modify DNS records within the zone. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param zone_name: The name of the DNS zone (without a terminating - dot). + :param zone_name: The name of the DNS zone (without a terminating dot). :type zone_name: str - :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. + :param parameters: Parameters supplied to the Update operation. + :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. :type if_match: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Zone or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Zone, or the result of cls(response) + :rtype: ~azure.mgmt.dns.v2018_05_01.models.Zone + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ZoneUpdate(tags=tags) + cls = kwargs.pop('cls', None) # type: ClsType["_models.Zone"] + error_map = { + 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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_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 self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ZoneUpdate') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Zone', response) + deserialized = self._deserialize('Zone', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :param top: The maximum number of record sets to return. If not specified, returns up to 100 + record sets. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2018_05_01.models.ZonePaged[~azure.mgmt.dns.v2018_05_01.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + 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') + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones'} # type: ignore def list( - self, top=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> 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. + :param top: The maximum number of DNS zones to return. If not specified, returns up to 100 + zones. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Zone - :rtype: - ~azure.mgmt.dns.v2018_05_01.models.ZonePaged[~azure.mgmt.dns.v2018_05_01.models.Zone] - :raises: :class:`CloudError` + :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 """ + 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'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ZoneListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ZonePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones'} + return ItemPaged( + get_next, extract_data + ) + 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/py.typed b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/network/azure-mgmt-dns/azure/mgmt/dns/v2018_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/network/azure-mgmt-dns/setup.py b/sdk/network/azure-mgmt-dns/setup.py index 14c3e0e1b201..43ecde3ac721 100644 --- a/sdk/network/azure-mgmt-dns/setup.py +++ b/sdk/network/azure-mgmt-dns/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -79,8 +81,8 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', ], extras_require={ ":python_version<'3.0'": ['azure-mgmt-nspkg'], diff --git a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py index 5b5b43c0f640..863498582f85 100644 --- a/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py +++ b/sdk/network/azure-mgmt-dns/tests/test_mgmt_dns.py @@ -173,7 +173,7 @@ def test_public_zone(self, resource_group, location): 'A' ) - async_delete = self.dns_client.zones.delete( + async_delete = self.dns_client.zones.begin_delete( resource_group.name, zone.name ) @@ -275,7 +275,7 @@ def test_private_zone(self, resource_group, location, registration_virtual_netwo 'A' ) - async_delete = self.dns_client.zones.delete( + async_delete = self.dns_client.zones.begin_delete( resource_group.name, zone.name )