diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json b/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json index 5403f47ba700..2e99fcb0b901 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "78f1d9d2be5ae24a9bebb5a62158f04d9cb7f69f", + "commit": "bd05dd03d03343e1942fd2bc6a6e21946a3e307c", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/dnsresolver/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/dnsresolver/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/dnsresolver/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py index c5378e850db8..6263ce26b82e 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['DnsResolverManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py index aa80881f1a07..b7a25fca0fb2 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class DnsResolverManagementClientConfiguration(Configuration): +class DnsResolverManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsResolverManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class DnsResolverManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-04-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dnsresolver/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py index 7f389b0e6ddf..18d02fd9395c 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_dns_resolver_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import DnsResolverManagementClientConfiguration @@ -25,27 +26,27 @@ class DnsResolverManagementClient: """The DNS Resolver Management Client. :ivar dns_resolvers: DnsResolversOperations operations - :vartype dns_resolvers: dns_resolver_management_client.operations.DnsResolversOperations + :vartype dns_resolvers: azure.mgmt.dnsresolver.operations.DnsResolversOperations :ivar inbound_endpoints: InboundEndpointsOperations operations - :vartype inbound_endpoints: - dns_resolver_management_client.operations.InboundEndpointsOperations + :vartype inbound_endpoints: azure.mgmt.dnsresolver.operations.InboundEndpointsOperations :ivar outbound_endpoints: OutboundEndpointsOperations operations - :vartype outbound_endpoints: - dns_resolver_management_client.operations.OutboundEndpointsOperations + :vartype outbound_endpoints: azure.mgmt.dnsresolver.operations.OutboundEndpointsOperations :ivar dns_forwarding_rulesets: DnsForwardingRulesetsOperations operations :vartype dns_forwarding_rulesets: - dns_resolver_management_client.operations.DnsForwardingRulesetsOperations + azure.mgmt.dnsresolver.operations.DnsForwardingRulesetsOperations :ivar forwarding_rules: ForwardingRulesOperations operations - :vartype forwarding_rules: dns_resolver_management_client.operations.ForwardingRulesOperations + :vartype forwarding_rules: azure.mgmt.dnsresolver.operations.ForwardingRulesOperations :ivar virtual_network_links: VirtualNetworkLinksOperations operations - :vartype virtual_network_links: - dns_resolver_management_client.operations.VirtualNetworkLinksOperations + :vartype virtual_network_links: azure.mgmt.dnsresolver.operations.VirtualNetworkLinksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -64,17 +65,29 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.dns_resolvers = DnsResolversOperations(self._client, self._config, self._serialize, self._deserialize) - self.inbound_endpoints = InboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.outbound_endpoints = OutboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.forwarding_rules = ForwardingRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_links = VirtualNetworkLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resolvers = DnsResolversOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.inbound_endpoints = InboundEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_endpoints = OutboundEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.forwarding_rules = ForwardingRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_network_links = VirtualNetworkLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json deleted file mode 100644 index f53b47be216e..000000000000 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "chosen_version": "2020-04-01-preview", - "total_api_version_list": ["2020-04-01-preview"], - "client": { - "name": "DnsResolverManagementClient", - "filename": "_dns_resolver_management_client", - "description": "The DNS Resolver Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsResolverManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DnsResolverManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "dns_resolvers": "DnsResolversOperations", - "inbound_endpoints": "InboundEndpointsOperations", - "outbound_endpoints": "OutboundEndpointsOperations", - "dns_forwarding_rulesets": "DnsForwardingRulesetsOperations", - "forwarding_rules": "ForwardingRulesOperations", - "virtual_network_links": "VirtualNetworkLinksOperations" - } -} \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py index 60222ade089f..13df2d7ac434 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._dns_resolver_management_client import DnsResolverManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['DnsResolverManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py index 8b6c7fd3310e..e4d514349a2b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DnsResolverManagementClientConfiguration(Configuration): +class DnsResolverManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DnsResolverManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class DnsResolverManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(DnsResolverManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-07-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-04-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-dnsresolver/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py index 69292fa1c1ce..8eafd5b0c355 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/_dns_resolver_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import DnsResolverManagementClientConfiguration @@ -25,28 +26,28 @@ class DnsResolverManagementClient: """The DNS Resolver Management Client. :ivar dns_resolvers: DnsResolversOperations operations - :vartype dns_resolvers: dns_resolver_management_client.aio.operations.DnsResolversOperations + :vartype dns_resolvers: azure.mgmt.dnsresolver.aio.operations.DnsResolversOperations :ivar inbound_endpoints: InboundEndpointsOperations operations - :vartype inbound_endpoints: - dns_resolver_management_client.aio.operations.InboundEndpointsOperations + :vartype inbound_endpoints: azure.mgmt.dnsresolver.aio.operations.InboundEndpointsOperations :ivar outbound_endpoints: OutboundEndpointsOperations operations - :vartype outbound_endpoints: - dns_resolver_management_client.aio.operations.OutboundEndpointsOperations + :vartype outbound_endpoints: azure.mgmt.dnsresolver.aio.operations.OutboundEndpointsOperations :ivar dns_forwarding_rulesets: DnsForwardingRulesetsOperations operations :vartype dns_forwarding_rulesets: - dns_resolver_management_client.aio.operations.DnsForwardingRulesetsOperations + azure.mgmt.dnsresolver.aio.operations.DnsForwardingRulesetsOperations :ivar forwarding_rules: ForwardingRulesOperations operations - :vartype forwarding_rules: - dns_resolver_management_client.aio.operations.ForwardingRulesOperations + :vartype forwarding_rules: azure.mgmt.dnsresolver.aio.operations.ForwardingRulesOperations :ivar virtual_network_links: VirtualNetworkLinksOperations operations :vartype virtual_network_links: - dns_resolver_management_client.aio.operations.VirtualNetworkLinksOperations + azure.mgmt.dnsresolver.aio.operations.VirtualNetworkLinksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -65,12 +66,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.dns_resolvers = DnsResolversOperations(self._client, self._config, self._serialize, self._deserialize) - self.inbound_endpoints = InboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.outbound_endpoints = OutboundEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.forwarding_rules = ForwardingRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_links = VirtualNetworkLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.dns_resolvers = DnsResolversOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.inbound_endpoints = InboundEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_endpoints = OutboundEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dns_forwarding_rulesets = DnsForwardingRulesetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.forwarding_rules = ForwardingRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_network_links = VirtualNetworkLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py index 6656675bef07..28bbcbeb5407 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/__init__.py @@ -13,6 +13,9 @@ from ._forwarding_rules_operations import ForwardingRulesOperations from ._virtual_network_links_operations import VirtualNetworkLinksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DnsResolversOperations', 'InboundEndpointsOperations', @@ -21,3 +24,5 @@ 'ForwardingRulesOperations', 'VirtualNetworkLinksOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py index cc5966db1b25..a88a0b32d59b 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_forwarding_rulesets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,43 +27,45 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DnsForwardingRulesetsOperations: - """DnsForwardingRulesetsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_forwarding_rulesets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRuleset", + parameters: _models.DnsForwardingRuleset, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsForwardingRuleset"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + ) -> Optional[_models.DnsForwardingRuleset]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsForwardingRuleset]] _json = self._serialize.body(parameters, 'DnsForwardingRuleset') @@ -71,16 +73,23 @@ async def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -99,7 +108,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace_async @@ -107,11 +116,11 @@ async def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRuleset", + parameters: _models.DnsForwardingRuleset, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.DnsForwardingRuleset"]: + ) -> AsyncLROPoller[_models.DnsForwardingRuleset]: """Creates or updates a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,13 +128,13 @@ async def begin_create_or_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.DnsForwardingRuleset + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -137,41 +146,52 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DnsForwardingRuleset or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -180,26 +200,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore async def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRulesetPatch", + parameters: _models.DnsForwardingRulesetPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsForwardingRuleset"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + ) -> Optional[_models.DnsForwardingRuleset]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsForwardingRuleset]] _json = self._serialize.body(parameters, 'DnsForwardingRulesetPatch') @@ -207,15 +230,22 @@ async def _update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -231,7 +261,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace_async @@ -239,10 +269,10 @@ async def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRulesetPatch", + parameters: _models.DnsForwardingRulesetPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.DnsForwardingRuleset"]: + ) -> AsyncLROPoller[_models.DnsForwardingRuleset]: """Updates a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -250,10 +280,10 @@ async def begin_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.DnsForwardingRulesetPatch + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -265,40 +295,51 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DnsForwardingRuleset or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -307,36 +348,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -346,11 +398,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -366,7 +418,7 @@ async def begin_delete( :type dns_forwarding_ruleset_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -380,19 +432,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -402,8 +461,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -412,10 +477,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace_async async def get( @@ -423,7 +487,7 @@ async def get( resource_group_name: str, dns_forwarding_ruleset_name: str, **kwargs: Any - ) -> "_models.DnsForwardingRuleset": + ) -> _models.DnsForwardingRuleset: """Gets a DNS forwarding ruleset properties. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -432,26 +496,38 @@ async def get( :type dns_forwarding_ruleset_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsForwardingRuleset, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.DnsForwardingRuleset + :rtype: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,7 +541,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace @@ -474,48 +550,59 @@ def list_by_resource_group( resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DnsForwardingRulesetListResult"]: + ) -> AsyncIterable[_models.DnsForwardingRulesetListResult]: """Lists DNS forwarding rulesets within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -529,7 +616,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,51 +633,62 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets"} # type: ignore @distributed_trace def list( self, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DnsForwardingRulesetListResult"]: + ) -> AsyncIterable[_models.DnsForwardingRulesetListResult]: """Lists DNS forwarding rulesets in all resource groups of a subscription. :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -600,7 +702,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -613,7 +719,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets"} # type: ignore @distributed_trace def list_by_virtual_network( @@ -622,7 +728,7 @@ def list_by_virtual_network( virtual_network_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualNetworkDnsForwardingRulesetListResult"]: + ) -> AsyncIterable[_models.VirtualNetworkDnsForwardingRulesetListResult]: """Lists DNS forwarding ruleset resource IDs attached to a virtual network. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -630,20 +736,25 @@ def list_by_virtual_network( :param virtual_network_name: The name of the virtual network. :type virtual_network_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworkDnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRulesetListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkDnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkDnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkDnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -651,11 +762,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=self.list_by_virtual_network.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -663,11 +777,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -681,7 +798,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,4 +815,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets'} # type: ignore + list_by_virtual_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py index 53df75f1cc7b..26a0045a9e4f 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_dns_resolvers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,43 +27,45 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DnsResolversOperations: - """DnsResolversOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`dns_resolvers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolver", + parameters: _models.DnsResolver, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsResolver"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + ) -> Optional[_models.DnsResolver]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsResolver]] _json = self._serialize.body(parameters, 'DnsResolver') @@ -71,16 +73,23 @@ async def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -99,7 +108,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace_async @@ -107,11 +116,11 @@ async def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolver", + parameters: _models.DnsResolver, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.DnsResolver"]: + ) -> AsyncLROPoller[_models.DnsResolver]: """Creates or updates a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -119,13 +128,13 @@ async def begin_create_or_update( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.DnsResolver + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -137,40 +146,52 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DnsResolver or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsResolver] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsResolver', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -179,26 +200,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolverPatch", + parameters: _models.DnsResolverPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsResolver"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + ) -> Optional[_models.DnsResolver]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsResolver]] _json = self._serialize.body(parameters, 'DnsResolverPatch') @@ -206,15 +230,22 @@ async def _update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,7 +261,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace_async @@ -238,10 +269,10 @@ async def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolverPatch", + parameters: _models.DnsResolverPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.DnsResolver"]: + ) -> AsyncLROPoller[_models.DnsResolver]: """Updates a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -249,10 +280,10 @@ async def begin_update( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.DnsResolverPatch + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -264,39 +295,51 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DnsResolver or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.DnsResolver] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsResolver', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -305,36 +348,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -344,11 +398,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -363,7 +417,7 @@ async def begin_delete( :type dns_resolver_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -377,19 +431,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -399,8 +460,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -409,10 +476,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace_async async def get( @@ -420,7 +486,7 @@ async def get( resource_group_name: str, dns_resolver_name: str, **kwargs: Any - ) -> "_models.DnsResolver": + ) -> _models.DnsResolver: """Gets properties of a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -429,26 +495,38 @@ async def get( :type dns_resolver_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResolver, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.DnsResolver + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolver :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -462,7 +540,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace @@ -471,48 +549,59 @@ def list_by_resource_group( resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DnsResolverListResult"]: + ) -> AsyncIterable[_models.DnsResolverListResult]: """Lists DNS resolvers within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsResolverListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolverListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -526,7 +615,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -539,51 +632,62 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers"} # type: ignore @distributed_trace def list( self, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DnsResolverListResult"]: + ) -> AsyncIterable[_models.DnsResolverListResult]: """Lists DNS resolvers in all resource groups of a subscription. :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsResolverListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolverListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -597,7 +701,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -610,7 +718,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers"} # type: ignore @distributed_trace def list_by_virtual_network( @@ -619,7 +727,7 @@ def list_by_virtual_network( virtual_network_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubResourceListResult"]: + ) -> AsyncIterable[_models.SubResourceListResult]: """Lists DNS resolver resource IDs linked to a virtual network. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -627,20 +735,25 @@ def list_by_virtual_network( :param virtual_network_name: The name of the virtual network. :type virtual_network_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubResourceListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.SubResourceListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.SubResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubResourceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -648,11 +761,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=self.list_by_virtual_network.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -660,11 +776,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -678,7 +797,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -691,4 +814,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers'} # type: ignore + list_by_virtual_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py index 074c4f8a108d..a93c3525e2d7 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_forwarding_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ForwardingRulesOperations: - """ForwardingRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`forwarding_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( @@ -52,11 +50,11 @@ async def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: "_models.ForwardingRule", + parameters: _models.ForwardingRule, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Creates or updates a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,26 +64,30 @@ async def create_or_update( :param forwarding_rule_name: The name of the forwarding rule. :type forwarding_rule_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.ForwardingRule + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] _json = self._serialize.body(parameters, 'ForwardingRule') @@ -94,16 +96,23 @@ async def create_or_update( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -121,7 +130,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace_async @@ -130,10 +139,10 @@ async def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: "_models.ForwardingRulePatch", + parameters: _models.ForwardingRulePatch, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Updates a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -143,23 +152,27 @@ async def update( :param forwarding_rule_name: The name of the forwarding rule. :type forwarding_rule_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.ForwardingRulePatch + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] _json = self._serialize.body(parameters, 'ForwardingRulePatch') @@ -168,15 +181,22 @@ async def update( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,11 +210,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -213,18 +233,23 @@ async def delete( :type forwarding_rule_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -232,13 +257,20 @@ async def delete( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -248,7 +280,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace_async @@ -258,7 +290,7 @@ async def get( dns_forwarding_ruleset_name: str, forwarding_rule_name: str, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Gets properties of a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -269,14 +301,19 @@ async def get( :type forwarding_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] request = build_get_request( @@ -284,12 +321,19 @@ async def get( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +347,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace @@ -313,7 +357,7 @@ def list( dns_forwarding_ruleset_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ForwardingRuleListResult"]: + ) -> AsyncIterable[_models.ForwardingRuleListResult]: """Lists forwarding rules in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -321,20 +365,25 @@ def list( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ForwardingRuleListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.ForwardingRuleListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.ForwardingRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -342,11 +391,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -354,11 +406,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -372,7 +427,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -385,4 +444,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py index 5dadba3dec11..d5ef946287fd 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_inbound_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,44 +27,46 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class InboundEndpointsOperations: - """InboundEndpointsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`inbound_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpoint", + parameters: _models.InboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.InboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + ) -> Optional[_models.InboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.InboundEndpoint]] _json = self._serialize.body(parameters, 'InboundEndpoint') @@ -73,16 +75,23 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -101,7 +110,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace_async @@ -110,11 +119,11 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpoint", + parameters: _models.InboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.InboundEndpoint"]: + ) -> AsyncLROPoller[_models.InboundEndpoint]: """Creates or updates an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -124,13 +133,13 @@ async def begin_create_or_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.InboundEndpoint + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -142,42 +151,53 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either InboundEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('InboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -186,27 +206,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpointPatch", + parameters: _models.InboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.InboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + ) -> Optional[_models.InboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.InboundEndpoint]] _json = self._serialize.body(parameters, 'InboundEndpointPatch') @@ -215,15 +238,22 @@ async def _update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,7 +269,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace_async @@ -248,10 +278,10 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpointPatch", + parameters: _models.InboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.InboundEndpoint"]: + ) -> AsyncLROPoller[_models.InboundEndpoint]: """Updates an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -261,10 +291,10 @@ async def begin_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.InboundEndpointPatch + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -276,41 +306,52 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either InboundEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('InboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -319,12 +360,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -332,11 +372,16 @@ async def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -344,13 +389,20 @@ async def _delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -360,11 +412,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -382,7 +434,7 @@ async def begin_delete( :type inbound_endpoint_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -396,20 +448,27 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -419,8 +478,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -429,10 +494,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace_async async def get( @@ -441,7 +505,7 @@ async def get( dns_resolver_name: str, inbound_endpoint_name: str, **kwargs: Any - ) -> "_models.InboundEndpoint": + ) -> _models.InboundEndpoint: """Gets properties of an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -452,14 +516,19 @@ async def get( :type inbound_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: InboundEndpoint, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.InboundEndpoint + :rtype: ~azure.mgmt.dnsresolver.models.InboundEndpoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] request = build_get_request( @@ -467,12 +536,19 @@ async def get( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -486,7 +562,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace @@ -496,7 +572,7 @@ def list( dns_resolver_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.InboundEndpointListResult"]: + ) -> AsyncIterable[_models.InboundEndpointListResult]: """Lists inbound endpoints for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -504,20 +580,25 @@ def list( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either InboundEndpointListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.InboundEndpointListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.InboundEndpointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpointListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,11 +606,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -537,11 +621,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -555,7 +642,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,4 +659,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py index 8ad36befea6e..96b80074aef1 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_outbound_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,44 +27,46 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OutboundEndpointsOperations: - """OutboundEndpointsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`outbound_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpoint", + parameters: _models.OutboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.OutboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + ) -> Optional[_models.OutboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OutboundEndpoint]] _json = self._serialize.body(parameters, 'OutboundEndpoint') @@ -73,16 +75,23 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -101,7 +110,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace_async @@ -110,11 +119,11 @@ async def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpoint", + parameters: _models.OutboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OutboundEndpoint"]: + ) -> AsyncLROPoller[_models.OutboundEndpoint]: """Creates or updates an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -124,13 +133,13 @@ async def begin_create_or_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.OutboundEndpoint + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -142,42 +151,53 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OutboundEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('OutboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -186,27 +206,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore async def _update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpointPatch", + parameters: _models.OutboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.OutboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + ) -> Optional[_models.OutboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OutboundEndpoint]] _json = self._serialize.body(parameters, 'OutboundEndpointPatch') @@ -215,15 +238,22 @@ async def _update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,7 +269,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace_async @@ -248,10 +278,10 @@ async def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpointPatch", + parameters: _models.OutboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OutboundEndpoint"]: + ) -> AsyncLROPoller[_models.OutboundEndpoint]: """Updates an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -261,10 +291,10 @@ async def begin_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.OutboundEndpointPatch + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -276,41 +306,52 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OutboundEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('OutboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -319,12 +360,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -332,11 +372,16 @@ async def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -344,13 +389,20 @@ async def _delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -360,11 +412,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -382,7 +434,7 @@ async def begin_delete( :type outbound_endpoint_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -396,20 +448,27 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -419,8 +478,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -429,10 +494,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace_async async def get( @@ -441,7 +505,7 @@ async def get( dns_resolver_name: str, outbound_endpoint_name: str, **kwargs: Any - ) -> "_models.OutboundEndpoint": + ) -> _models.OutboundEndpoint: """Gets properties of an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -452,14 +516,19 @@ async def get( :type outbound_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OutboundEndpoint, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.OutboundEndpoint + :rtype: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] request = build_get_request( @@ -467,12 +536,19 @@ async def get( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -486,7 +562,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace @@ -496,7 +572,7 @@ def list( dns_resolver_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.OutboundEndpointListResult"]: + ) -> AsyncIterable[_models.OutboundEndpointListResult]: """Lists outbound endpoints for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -504,20 +580,25 @@ def list( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEndpointListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.OutboundEndpointListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.OutboundEndpointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpointListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,11 +606,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -537,11 +621,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -555,7 +642,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,4 +659,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py index 7bc901dd15a4..3ba02ba511a7 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/aio/operations/_virtual_network_links_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,44 +27,46 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualNetworkLinksOperations: - """VirtualNetworkLinksOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.aio.DnsResolverManagementClient`'s + :attr:`virtual_network_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLink", + parameters: _models.VirtualNetworkLink, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.VirtualNetworkLink"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + ) -> Optional[_models.VirtualNetworkLink]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualNetworkLink]] _json = self._serialize.body(parameters, 'VirtualNetworkLink') @@ -73,16 +75,23 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -101,7 +110,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace_async @@ -110,11 +119,11 @@ async def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLink", + parameters: _models.VirtualNetworkLink, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualNetworkLink"]: + ) -> AsyncLROPoller[_models.VirtualNetworkLink]: """Creates or updates a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -124,13 +133,13 @@ async def begin_create_or_update( :param virtual_network_link_name: The name of the virtual network link. :type virtual_network_link_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLink + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -142,42 +151,53 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualNetworkLink or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -186,27 +206,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore async def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLinkPatch", + parameters: _models.VirtualNetworkLinkPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.VirtualNetworkLink"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + ) -> Optional[_models.VirtualNetworkLink]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualNetworkLink]] _json = self._serialize.body(parameters, 'VirtualNetworkLinkPatch') @@ -215,15 +238,22 @@ async def _update_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,7 +269,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace_async @@ -248,10 +278,10 @@ async def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLinkPatch", + parameters: _models.VirtualNetworkLinkPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualNetworkLink"]: + ) -> AsyncLROPoller[_models.VirtualNetworkLink]: """Updates a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -261,10 +291,10 @@ async def begin_update( :param virtual_network_link_name: The name of the virtual network link. :type virtual_network_link_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLinkPatch + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -276,41 +306,52 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualNetworkLink or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -319,12 +360,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -332,11 +372,16 @@ async def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -344,13 +389,20 @@ async def _delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -360,11 +412,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -383,7 +435,7 @@ async def begin_delete( :type virtual_network_link_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -397,20 +449,27 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] 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( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -420,8 +479,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -430,10 +495,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace_async async def get( @@ -442,7 +506,7 @@ async def get( dns_forwarding_ruleset_name: str, virtual_network_link_name: str, **kwargs: Any - ) -> "_models.VirtualNetworkLink": + ) -> _models.VirtualNetworkLink: """Gets properties of a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -453,14 +517,19 @@ async def get( :type virtual_network_link_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualNetworkLink, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.VirtualNetworkLink + :rtype: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] request = build_get_request( @@ -468,12 +537,19 @@ async def get( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -487,7 +563,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace @@ -497,7 +573,7 @@ def list( dns_forwarding_ruleset_name: str, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualNetworkLinkListResult"]: + ) -> AsyncIterable[_models.VirtualNetworkLinkListResult]: """Lists virtual network links to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -505,20 +581,25 @@ def list( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworkLinkListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~dns_resolver_management_client.models.VirtualNetworkLinkListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLinkListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLinkListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,11 +607,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -538,11 +622,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -556,7 +643,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -569,4 +660,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py index dbfbfbf78a28..0c2ea62ebcad 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/__init__.py @@ -44,7 +44,9 @@ IpAllocationMethod, ProvisioningState, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'CloudErrorBody', 'DnsForwardingRuleset', @@ -81,3 +83,5 @@ 'IpAllocationMethod', 'ProvisioningState', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py index 68eb47d397ea..ca03fbb2fb9a 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_dns_resolver_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -20,7 +19,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DnsResolverState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DnsResolverState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current status of the DNS resolver. This is a read-only property and any attempt to set this value will be ignored. """ @@ -28,21 +27,21 @@ class DnsResolverState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CONNECTED = "Connected" DISCONNECTED = "Disconnected" -class ForwardingRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ForwardingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of forwarding rule. """ ENABLED = "Enabled" DISABLED = "Disabled" -class IpAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IpAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Private IP address allocation method. """ STATIC = "Static" DYNAMIC = "Dynamic" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state of the resource. """ diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py index d4fbc6749f77..9826020996a5 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._dns_resolver_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class CloudErrorBody(msrest.serialization.Model): @@ -24,7 +26,7 @@ class CloudErrorBody(msrest.serialization.Model): :ivar target: The target resource of the error message. :vartype target: str :ivar details: Extra error information. - :vartype details: list[~dns_resolver_management_client.models.CloudErrorBody] + :vartype details: list[~azure.mgmt.dnsresolver.models.CloudErrorBody] """ _attribute_map = { @@ -40,7 +42,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -51,7 +53,7 @@ def __init__( :keyword target: The target resource of the error message. :paramtype target: str :keyword details: Extra error information. - :paramtype details: list[~dns_resolver_management_client.models.CloudErrorBody] + :paramtype details: list[~azure.mgmt.dnsresolver.models.CloudErrorBody] """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code @@ -175,16 +177,15 @@ class DnsForwardingRuleset(TrackedResource): :ivar etag: ETag of the DNS forwarding ruleset. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints - that are used to route DNS queries matching the forwarding rules in the ruleset to the target - DNS servers. - :vartype dns_resolver_outbound_endpoints: - list[~dns_resolver_management_client.models.SubResource] + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar dns_resolver_outbound_endpoints: Required. The reference to the DNS resolver outbound + endpoints that are used to route DNS queries matching the forwarding rules in the ruleset to + the target DNS servers. + :vartype dns_resolver_outbound_endpoints: list[~azure.mgmt.dnsresolver.models.SubResource] :ivar provisioning_state: The current provisioning state of the DNS forwarding ruleset. This is - a read-only property and any attempt to set this value will be ignored. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + a read-only property and any attempt to set this value will be ignored. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState :ivar resource_guid: The resourceGuid for the DNS forwarding ruleset. :vartype resource_guid: str """ @@ -196,6 +197,7 @@ class DnsForwardingRuleset(TrackedResource): 'location': {'required': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'dns_resolver_outbound_endpoints': {'required': True}, 'provisioning_state': {'readonly': True}, 'resource_guid': {'readonly': True}, } @@ -217,8 +219,8 @@ def __init__( self, *, location: str, + dns_resolver_outbound_endpoints: List["_models.SubResource"], tags: Optional[Dict[str, str]] = None, - dns_resolver_outbound_endpoints: Optional[List["SubResource"]] = None, **kwargs ): """ @@ -226,11 +228,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str - :keyword dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints - that are used to route DNS queries matching the forwarding rules in the ruleset to the target - DNS servers. - :paramtype dns_resolver_outbound_endpoints: - list[~dns_resolver_management_client.models.SubResource] + :keyword dns_resolver_outbound_endpoints: Required. The reference to the DNS resolver outbound + endpoints that are used to route DNS queries matching the forwarding rules in the ruleset to + the target DNS servers. + :paramtype dns_resolver_outbound_endpoints: list[~azure.mgmt.dnsresolver.models.SubResource] """ super(DnsForwardingRuleset, self).__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -246,7 +247,7 @@ class DnsForwardingRulesetListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the DNS forwarding rulesets. - :vartype value: list[~dns_resolver_management_client.models.DnsForwardingRuleset] + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -263,12 +264,12 @@ class DnsForwardingRulesetListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DnsForwardingRuleset"]] = None, + value: Optional[List["_models.DnsForwardingRuleset"]] = None, **kwargs ): """ :keyword value: Enumeration of the DNS forwarding rulesets. - :paramtype value: list[~dns_resolver_management_client.models.DnsForwardingRuleset] + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] """ super(DnsForwardingRulesetListResult, self).__init__(**kwargs) self.value = value @@ -278,25 +279,36 @@ def __init__( class DnsForwardingRulesetPatch(msrest.serialization.Model): """Describes a DNS forwarding ruleset PATCH operation. + :ivar dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints + that are used to route DNS queries matching the forwarding rules in the ruleset to the target + DNS servers. + :vartype dns_resolver_outbound_endpoints: list[~azure.mgmt.dnsresolver.models.SubResource] :ivar tags: A set of tags. Tags for DNS Resolver. :vartype tags: dict[str, str] """ _attribute_map = { + 'dns_resolver_outbound_endpoints': {'key': 'dnsResolverOutboundEndpoints', 'type': '[SubResource]'}, 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, *, + dns_resolver_outbound_endpoints: Optional[List["_models.SubResource"]] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): """ + :keyword dns_resolver_outbound_endpoints: The reference to the DNS resolver outbound endpoints + that are used to route DNS queries matching the forwarding rules in the ruleset to the target + DNS servers. + :paramtype dns_resolver_outbound_endpoints: list[~azure.mgmt.dnsresolver.models.SubResource] :keyword tags: A set of tags. Tags for DNS Resolver. :paramtype tags: dict[str, str] """ super(DnsForwardingRulesetPatch, self).__init__(**kwargs) + self.dns_resolver_outbound_endpoints = dns_resolver_outbound_endpoints self.tags = tags @@ -322,18 +334,18 @@ class DnsResolver(TrackedResource): :ivar etag: ETag of the DNS resolver. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar virtual_network: The reference to the virtual network. This cannot be changed after - creation. - :vartype virtual_network: ~dns_resolver_management_client.models.SubResource + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar virtual_network: Required. The reference to the virtual network. This cannot be changed + after creation. + :vartype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource :ivar dns_resolver_state: The current status of the DNS resolver. This is a read-only property - and any attempt to set this value will be ignored. Possible values include: "Connected", + and any attempt to set this value will be ignored. Known values are: "Connected", "Disconnected". - :vartype dns_resolver_state: str or ~dns_resolver_management_client.models.DnsResolverState + :vartype dns_resolver_state: str or ~azure.mgmt.dnsresolver.models.DnsResolverState :ivar provisioning_state: The current provisioning state of the DNS resolver. This is a - read-only property and any attempt to set this value will be ignored. Possible values include: + read-only property and any attempt to set this value will be ignored. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState :ivar resource_guid: The resourceGuid property of the DNS resolver resource. :vartype resource_guid: str """ @@ -345,6 +357,7 @@ class DnsResolver(TrackedResource): 'location': {'required': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'virtual_network': {'required': True}, 'dns_resolver_state': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'resource_guid': {'readonly': True}, @@ -368,8 +381,8 @@ def __init__( self, *, location: str, + virtual_network: "_models.SubResource", tags: Optional[Dict[str, str]] = None, - virtual_network: Optional["SubResource"] = None, **kwargs ): """ @@ -377,9 +390,9 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str - :keyword virtual_network: The reference to the virtual network. This cannot be changed after - creation. - :paramtype virtual_network: ~dns_resolver_management_client.models.SubResource + :keyword virtual_network: Required. The reference to the virtual network. This cannot be + changed after creation. + :paramtype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource """ super(DnsResolver, self).__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -396,7 +409,7 @@ class DnsResolverListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the DNS resolvers. - :vartype value: list[~dns_resolver_management_client.models.DnsResolver] + :vartype value: list[~azure.mgmt.dnsresolver.models.DnsResolver] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -413,12 +426,12 @@ class DnsResolverListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DnsResolver"]] = None, + value: Optional[List["_models.DnsResolver"]] = None, **kwargs ): """ :keyword value: Enumeration of the DNS resolvers. - :paramtype value: list[~dns_resolver_management_client.models.DnsResolver] + :paramtype value: list[~azure.mgmt.dnsresolver.models.DnsResolver] """ super(DnsResolverListResult, self).__init__(**kwargs) self.value = value @@ -491,6 +504,8 @@ class ForwardingRule(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str @@ -502,21 +517,20 @@ class ForwardingRule(ProxyResource): :ivar etag: ETag of the forwarding rule. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar domain_name: The domain name for the forwarding rule. + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar domain_name: Required. The domain name for the forwarding rule. :vartype domain_name: str - :ivar target_dns_servers: DNS servers to forward the DNS query to. - :vartype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :ivar target_dns_servers: Required. DNS servers to forward the DNS query to. + :vartype target_dns_servers: list[~azure.mgmt.dnsresolver.models.TargetDnsServer] :ivar metadata: Metadata attached to the forwarding rule. :vartype metadata: dict[str, str] - :ivar forwarding_rule_state: The state of forwarding rule. Possible values include: "Enabled", + :ivar forwarding_rule_state: The state of forwarding rule. Known values are: "Enabled", "Disabled". - :vartype forwarding_rule_state: str or - ~dns_resolver_management_client.models.ForwardingRuleState + :vartype forwarding_rule_state: str or ~azure.mgmt.dnsresolver.models.ForwardingRuleState :ivar provisioning_state: The current provisioning state of the forwarding rule. This is a - read-only property and any attempt to set this value will be ignored. Possible values include: + read-only property and any attempt to set this value will be ignored. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState """ _validation = { @@ -525,6 +539,8 @@ class ForwardingRule(ProxyResource): 'type': {'readonly': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'domain_name': {'required': True}, + 'target_dns_servers': {'required': True}, 'provisioning_state': {'readonly': True}, } @@ -544,23 +560,22 @@ class ForwardingRule(ProxyResource): def __init__( self, *, - domain_name: Optional[str] = None, - target_dns_servers: Optional[List["TargetDnsServer"]] = None, + domain_name: str, + target_dns_servers: List["_models.TargetDnsServer"], metadata: Optional[Dict[str, str]] = None, - forwarding_rule_state: Optional[Union[str, "ForwardingRuleState"]] = None, + forwarding_rule_state: Optional[Union[str, "_models.ForwardingRuleState"]] = None, **kwargs ): """ - :keyword domain_name: The domain name for the forwarding rule. + :keyword domain_name: Required. The domain name for the forwarding rule. :paramtype domain_name: str - :keyword target_dns_servers: DNS servers to forward the DNS query to. - :paramtype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :keyword target_dns_servers: Required. DNS servers to forward the DNS query to. + :paramtype target_dns_servers: list[~azure.mgmt.dnsresolver.models.TargetDnsServer] :keyword metadata: Metadata attached to the forwarding rule. :paramtype metadata: dict[str, str] - :keyword forwarding_rule_state: The state of forwarding rule. Possible values include: - "Enabled", "Disabled". - :paramtype forwarding_rule_state: str or - ~dns_resolver_management_client.models.ForwardingRuleState + :keyword forwarding_rule_state: The state of forwarding rule. Known values are: "Enabled", + "Disabled". + :paramtype forwarding_rule_state: str or ~azure.mgmt.dnsresolver.models.ForwardingRuleState """ super(ForwardingRule, self).__init__(**kwargs) self.etag = None @@ -578,7 +593,7 @@ class ForwardingRuleListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the forwarding rules. - :vartype value: list[~dns_resolver_management_client.models.ForwardingRule] + :vartype value: list[~azure.mgmt.dnsresolver.models.ForwardingRule] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -595,12 +610,12 @@ class ForwardingRuleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ForwardingRule"]] = None, + value: Optional[List["_models.ForwardingRule"]] = None, **kwargs ): """ :keyword value: Enumeration of the forwarding rules. - :paramtype value: list[~dns_resolver_management_client.models.ForwardingRule] + :paramtype value: list[~azure.mgmt.dnsresolver.models.ForwardingRule] """ super(ForwardingRuleListResult, self).__init__(**kwargs) self.value = value @@ -611,13 +626,12 @@ class ForwardingRulePatch(msrest.serialization.Model): """Describes a forwarding rule for PATCH operation. :ivar target_dns_servers: DNS servers to forward the DNS query to. - :vartype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :vartype target_dns_servers: list[~azure.mgmt.dnsresolver.models.TargetDnsServer] :ivar metadata: Metadata attached to the forwarding rule. :vartype metadata: dict[str, str] - :ivar forwarding_rule_state: The state of forwarding rule. Possible values include: "Enabled", + :ivar forwarding_rule_state: The state of forwarding rule. Known values are: "Enabled", "Disabled". - :vartype forwarding_rule_state: str or - ~dns_resolver_management_client.models.ForwardingRuleState + :vartype forwarding_rule_state: str or ~azure.mgmt.dnsresolver.models.ForwardingRuleState """ _attribute_map = { @@ -629,20 +643,19 @@ class ForwardingRulePatch(msrest.serialization.Model): def __init__( self, *, - target_dns_servers: Optional[List["TargetDnsServer"]] = None, + target_dns_servers: Optional[List["_models.TargetDnsServer"]] = None, metadata: Optional[Dict[str, str]] = None, - forwarding_rule_state: Optional[Union[str, "ForwardingRuleState"]] = None, + forwarding_rule_state: Optional[Union[str, "_models.ForwardingRuleState"]] = None, **kwargs ): """ :keyword target_dns_servers: DNS servers to forward the DNS query to. - :paramtype target_dns_servers: list[~dns_resolver_management_client.models.TargetDnsServer] + :paramtype target_dns_servers: list[~azure.mgmt.dnsresolver.models.TargetDnsServer] :keyword metadata: Metadata attached to the forwarding rule. :paramtype metadata: dict[str, str] - :keyword forwarding_rule_state: The state of forwarding rule. Possible values include: - "Enabled", "Disabled". - :paramtype forwarding_rule_state: str or - ~dns_resolver_management_client.models.ForwardingRuleState + :keyword forwarding_rule_state: The state of forwarding rule. Known values are: "Enabled", + "Disabled". + :paramtype forwarding_rule_state: str or ~azure.mgmt.dnsresolver.models.ForwardingRuleState """ super(ForwardingRulePatch, self).__init__(**kwargs) self.target_dns_servers = target_dns_servers @@ -672,13 +685,13 @@ class InboundEndpoint(TrackedResource): :ivar etag: ETag of the inbound endpoint. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar ip_configurations: IP configurations for the inbound endpoint. - :vartype ip_configurations: list[~dns_resolver_management_client.models.IpConfiguration] + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar ip_configurations: Required. IP configurations for the inbound endpoint. + :vartype ip_configurations: list[~azure.mgmt.dnsresolver.models.IpConfiguration] :ivar provisioning_state: The current provisioning state of the inbound endpoint. This is a - read-only property and any attempt to set this value will be ignored. Possible values include: + read-only property and any attempt to set this value will be ignored. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState :ivar resource_guid: The resourceGuid property of the inbound endpoint resource. :vartype resource_guid: str """ @@ -690,6 +703,7 @@ class InboundEndpoint(TrackedResource): 'location': {'required': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'ip_configurations': {'required': True}, 'provisioning_state': {'readonly': True}, 'resource_guid': {'readonly': True}, } @@ -711,8 +725,8 @@ def __init__( self, *, location: str, + ip_configurations: List["_models.IpConfiguration"], tags: Optional[Dict[str, str]] = None, - ip_configurations: Optional[List["IpConfiguration"]] = None, **kwargs ): """ @@ -720,8 +734,8 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str - :keyword ip_configurations: IP configurations for the inbound endpoint. - :paramtype ip_configurations: list[~dns_resolver_management_client.models.IpConfiguration] + :keyword ip_configurations: Required. IP configurations for the inbound endpoint. + :paramtype ip_configurations: list[~azure.mgmt.dnsresolver.models.IpConfiguration] """ super(InboundEndpoint, self).__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -737,7 +751,7 @@ class InboundEndpointListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the inbound endpoints for a DNS resolver. - :vartype value: list[~dns_resolver_management_client.models.InboundEndpoint] + :vartype value: list[~azure.mgmt.dnsresolver.models.InboundEndpoint] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -754,12 +768,12 @@ class InboundEndpointListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InboundEndpoint"]] = None, + value: Optional[List["_models.InboundEndpoint"]] = None, **kwargs ): """ :keyword value: Enumeration of the inbound endpoints for a DNS resolver. - :paramtype value: list[~dns_resolver_management_client.models.InboundEndpoint] + :paramtype value: list[~azure.mgmt.dnsresolver.models.InboundEndpoint] """ super(InboundEndpointListResult, self).__init__(**kwargs) self.value = value @@ -794,16 +808,21 @@ def __init__( class IpConfiguration(msrest.serialization.Model): """IP configuration. - :ivar subnet: The reference to the subnet bound to the IP configuration. - :vartype subnet: ~dns_resolver_management_client.models.SubResource + All required parameters must be populated in order to send to Azure. + + :ivar subnet: Required. The reference to the subnet bound to the IP configuration. + :vartype subnet: ~azure.mgmt.dnsresolver.models.SubResource :ivar private_ip_address: Private IP address of the IP configuration. :vartype private_ip_address: str - :ivar private_ip_allocation_method: Private IP address allocation method. Possible values - include: "Static", "Dynamic". Default value: "Dynamic". - :vartype private_ip_allocation_method: str or - ~dns_resolver_management_client.models.IpAllocationMethod + :ivar private_ip_allocation_method: Private IP address allocation method. Known values are: + "Static", "Dynamic". Default value: "Dynamic". + :vartype private_ip_allocation_method: str or ~azure.mgmt.dnsresolver.models.IpAllocationMethod """ + _validation = { + 'subnet': {'required': True}, + } + _attribute_map = { 'subnet': {'key': 'subnet', 'type': 'SubResource'}, 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, @@ -813,20 +832,20 @@ class IpConfiguration(msrest.serialization.Model): def __init__( self, *, - subnet: Optional["SubResource"] = None, + subnet: "_models.SubResource", private_ip_address: Optional[str] = None, - private_ip_allocation_method: Optional[Union[str, "IpAllocationMethod"]] = "Dynamic", + private_ip_allocation_method: Optional[Union[str, "_models.IpAllocationMethod"]] = "Dynamic", **kwargs ): """ - :keyword subnet: The reference to the subnet bound to the IP configuration. - :paramtype subnet: ~dns_resolver_management_client.models.SubResource + :keyword subnet: Required. The reference to the subnet bound to the IP configuration. + :paramtype subnet: ~azure.mgmt.dnsresolver.models.SubResource :keyword private_ip_address: Private IP address of the IP configuration. :paramtype private_ip_address: str - :keyword private_ip_allocation_method: Private IP address allocation method. Possible values - include: "Static", "Dynamic". Default value: "Dynamic". + :keyword private_ip_allocation_method: Private IP address allocation method. Known values are: + "Static", "Dynamic". Default value: "Dynamic". :paramtype private_ip_allocation_method: str or - ~dns_resolver_management_client.models.IpAllocationMethod + ~azure.mgmt.dnsresolver.models.IpAllocationMethod """ super(IpConfiguration, self).__init__(**kwargs) self.subnet = subnet @@ -856,13 +875,13 @@ class OutboundEndpoint(TrackedResource): :ivar etag: ETag of the outbound endpoint. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar subnet: The reference to the subnet used for the outbound endpoint. - :vartype subnet: ~dns_resolver_management_client.models.SubResource + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar subnet: Required. The reference to the subnet used for the outbound endpoint. + :vartype subnet: ~azure.mgmt.dnsresolver.models.SubResource :ivar provisioning_state: The current provisioning state of the outbound endpoint. This is a - read-only property and any attempt to set this value will be ignored. Possible values include: + read-only property and any attempt to set this value will be ignored. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState :ivar resource_guid: The resourceGuid property of the outbound endpoint resource. :vartype resource_guid: str """ @@ -874,6 +893,7 @@ class OutboundEndpoint(TrackedResource): 'location': {'required': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'subnet': {'required': True}, 'provisioning_state': {'readonly': True}, 'resource_guid': {'readonly': True}, } @@ -895,8 +915,8 @@ def __init__( self, *, location: str, + subnet: "_models.SubResource", tags: Optional[Dict[str, str]] = None, - subnet: Optional["SubResource"] = None, **kwargs ): """ @@ -904,8 +924,8 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: Required. The geo-location where the resource lives. :paramtype location: str - :keyword subnet: The reference to the subnet used for the outbound endpoint. - :paramtype subnet: ~dns_resolver_management_client.models.SubResource + :keyword subnet: Required. The reference to the subnet used for the outbound endpoint. + :paramtype subnet: ~azure.mgmt.dnsresolver.models.SubResource """ super(OutboundEndpoint, self).__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -921,7 +941,7 @@ class OutboundEndpointListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the outbound endpoints for a DNS resolver. - :vartype value: list[~dns_resolver_management_client.models.OutboundEndpoint] + :vartype value: list[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -938,12 +958,12 @@ class OutboundEndpointListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["OutboundEndpoint"]] = None, + value: Optional[List["_models.OutboundEndpoint"]] = None, **kwargs ): """ :keyword value: Enumeration of the outbound endpoints for a DNS resolver. - :paramtype value: list[~dns_resolver_management_client.models.OutboundEndpoint] + :paramtype value: list[~azure.mgmt.dnsresolver.models.OutboundEndpoint] """ super(OutboundEndpointListResult, self).__init__(**kwargs) self.value = value @@ -978,10 +998,16 @@ def __init__( class SubResource(msrest.serialization.Model): """Reference to another ARM resource. - :ivar id: Resource ID. + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. Resource ID. :vartype id: str """ + _validation = { + 'id': {'required': True}, + } + _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, } @@ -989,11 +1015,11 @@ class SubResource(msrest.serialization.Model): def __init__( self, *, - id: Optional[str] = None, + id: str, **kwargs ): """ - :keyword id: Resource ID. + :keyword id: Required. Resource ID. :paramtype id: str """ super(SubResource, self).__init__(**kwargs) @@ -1006,7 +1032,7 @@ class SubResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the sub-resources. - :vartype value: list[~dns_resolver_management_client.models.SubResource] + :vartype value: list[~azure.mgmt.dnsresolver.models.SubResource] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -1023,12 +1049,12 @@ class SubResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SubResource"]] = None, + value: Optional[List["_models.SubResource"]] = None, **kwargs ): """ :keyword value: Enumeration of the sub-resources. - :paramtype value: list[~dns_resolver_management_client.models.SubResource] + :paramtype value: list[~azure.mgmt.dnsresolver.models.SubResource] """ super(SubResourceListResult, self).__init__(**kwargs) self.value = value @@ -1040,16 +1066,16 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". - :vartype created_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :vartype created_by_type: str or ~azure.mgmt.dnsresolver.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :vartype last_modified_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.dnsresolver.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -1067,26 +1093,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :paramtype created_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.dnsresolver.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :paramtype last_modified_by_type: str or ~dns_resolver_management_client.models.CreatedByType + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.dnsresolver.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ @@ -1102,12 +1128,18 @@ def __init__( class TargetDnsServer(msrest.serialization.Model): """Describes a server to forward the DNS queries to. - :ivar ip_address: DNS server IP address. + All required parameters must be populated in order to send to Azure. + + :ivar ip_address: Required. DNS server IP address. :vartype ip_address: str :ivar port: DNS server port. :vartype port: int """ + _validation = { + 'ip_address': {'required': True}, + } + _attribute_map = { 'ip_address': {'key': 'ipAddress', 'type': 'str'}, 'port': {'key': 'port', 'type': 'int'}, @@ -1116,12 +1148,12 @@ class TargetDnsServer(msrest.serialization.Model): def __init__( self, *, - ip_address: Optional[str] = None, + ip_address: str, port: Optional[int] = 53, **kwargs ): """ - :keyword ip_address: DNS server IP address. + :keyword ip_address: Required. DNS server IP address. :paramtype ip_address: str :keyword port: DNS server port. :paramtype port: int @@ -1137,7 +1169,7 @@ class VirtualNetworkDnsForwardingRuleset(msrest.serialization.Model): :ivar id: DNS Forwarding Ruleset Resource ID. :vartype id: str :ivar virtual_network_link: The reference to the virtual network link. - :vartype virtual_network_link: ~dns_resolver_management_client.models.SubResource + :vartype virtual_network_link: ~azure.mgmt.dnsresolver.models.SubResource """ _attribute_map = { @@ -1149,14 +1181,14 @@ def __init__( self, *, id: Optional[str] = None, - virtual_network_link: Optional["SubResource"] = None, + virtual_network_link: Optional["_models.SubResource"] = None, **kwargs ): """ :keyword id: DNS Forwarding Ruleset Resource ID. :paramtype id: str :keyword virtual_network_link: The reference to the virtual network link. - :paramtype virtual_network_link: ~dns_resolver_management_client.models.SubResource + :paramtype virtual_network_link: ~azure.mgmt.dnsresolver.models.SubResource """ super(VirtualNetworkDnsForwardingRuleset, self).__init__(**kwargs) self.id = id @@ -1169,7 +1201,7 @@ class VirtualNetworkDnsForwardingRulesetListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the Virtual Network DNS Forwarding Ruleset. - :vartype value: list[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRuleset] + :vartype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkDnsForwardingRuleset] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -1186,13 +1218,12 @@ class VirtualNetworkDnsForwardingRulesetListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualNetworkDnsForwardingRuleset"]] = None, + value: Optional[List["_models.VirtualNetworkDnsForwardingRuleset"]] = None, **kwargs ): """ :keyword value: Enumeration of the Virtual Network DNS Forwarding Ruleset. - :paramtype value: - list[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRuleset] + :paramtype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkDnsForwardingRuleset] """ super(VirtualNetworkDnsForwardingRulesetListResult, self).__init__(**kwargs) self.value = value @@ -1204,6 +1235,8 @@ class VirtualNetworkLink(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str @@ -1215,16 +1248,16 @@ class VirtualNetworkLink(ProxyResource): :ivar etag: ETag of the virtual network link. :vartype etag: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~dns_resolver_management_client.models.SystemData - :ivar virtual_network: The reference to the virtual network. This cannot be changed after - creation. - :vartype virtual_network: ~dns_resolver_management_client.models.SubResource + :vartype system_data: ~azure.mgmt.dnsresolver.models.SystemData + :ivar virtual_network: Required. The reference to the virtual network. This cannot be changed + after creation. + :vartype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource :ivar metadata: Metadata attached to the virtual network link. :vartype metadata: dict[str, str] :ivar provisioning_state: The current provisioning state of the virtual network link. This is a - read-only property and any attempt to set this value will be ignored. Possible values include: + read-only property and any attempt to set this value will be ignored. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". - :vartype provisioning_state: str or ~dns_resolver_management_client.models.ProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.dnsresolver.models.ProvisioningState """ _validation = { @@ -1233,6 +1266,7 @@ class VirtualNetworkLink(ProxyResource): 'type': {'readonly': True}, 'etag': {'readonly': True}, 'system_data': {'readonly': True}, + 'virtual_network': {'required': True}, 'provisioning_state': {'readonly': True}, } @@ -1250,14 +1284,14 @@ class VirtualNetworkLink(ProxyResource): def __init__( self, *, - virtual_network: Optional["SubResource"] = None, + virtual_network: "_models.SubResource", metadata: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword virtual_network: The reference to the virtual network. This cannot be changed after - creation. - :paramtype virtual_network: ~dns_resolver_management_client.models.SubResource + :keyword virtual_network: Required. The reference to the virtual network. This cannot be + changed after creation. + :paramtype virtual_network: ~azure.mgmt.dnsresolver.models.SubResource :keyword metadata: Metadata attached to the virtual network link. :paramtype metadata: dict[str, str] """ @@ -1275,7 +1309,7 @@ class VirtualNetworkLinkListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Enumeration of the virtual network links. - :vartype value: list[~dns_resolver_management_client.models.VirtualNetworkLink] + :vartype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :ivar next_link: The continuation token for the next page of results. :vartype next_link: str """ @@ -1292,12 +1326,12 @@ class VirtualNetworkLinkListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualNetworkLink"]] = None, + value: Optional[List["_models.VirtualNetworkLink"]] = None, **kwargs ): """ :keyword value: Enumeration of the virtual network links. - :paramtype value: list[~dns_resolver_management_client.models.VirtualNetworkLink] + :paramtype value: list[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] """ super(VirtualNetworkLinkListResult, self).__init__(**kwargs) self.value = value diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py index 6656675bef07..28bbcbeb5407 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/__init__.py @@ -13,6 +13,9 @@ from ._forwarding_rules_operations import ForwardingRulesOperations from ._virtual_network_links_operations import VirtualNetworkLinksOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DnsResolversOperations', 'InboundEndpointsOperations', @@ -21,3 +24,5 @@ 'ForwardingRulesOperations', 'VirtualNetworkLinksOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py index a3a29c5c21f9..7b69e3d87af6 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_forwarding_rulesets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,45 +34,46 @@ def build_create_or_update_request_initial( resource_group_name: str, dns_forwarding_ruleset_name: str, *, - json: JSONType = None, + json: Optional[_models.DnsForwardingRuleset] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,42 +85,43 @@ def build_update_request_initial( resource_group_name: str, dns_forwarding_ruleset_name: str, *, - json: JSONType = None, + json: Optional[_models.DnsForwardingRulesetPatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -134,33 +136,35 @@ def build_delete_request_initial( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -171,31 +175,33 @@ def build_get_request( dns_forwarding_ruleset_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -207,32 +213,34 @@ def build_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -243,31 +251,33 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -280,74 +290,78 @@ def build_list_by_virtual_network_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DnsForwardingRulesetsOperations(object): - """DnsForwardingRulesetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DnsForwardingRulesetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_forwarding_rulesets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRuleset", + parameters: _models.DnsForwardingRuleset, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsForwardingRuleset"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + ) -> Optional[_models.DnsForwardingRuleset]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsForwardingRuleset]] _json = self._serialize.body(parameters, 'DnsForwardingRuleset') @@ -355,16 +369,23 @@ def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -383,7 +404,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace @@ -391,11 +412,11 @@ def begin_create_or_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRuleset", + parameters: _models.DnsForwardingRuleset, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.DnsForwardingRuleset"]: + ) -> LROPoller[_models.DnsForwardingRuleset]: """Creates or updates a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -403,13 +424,13 @@ def begin_create_or_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.DnsForwardingRuleset + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -421,41 +442,52 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either DnsForwardingRuleset or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -464,26 +496,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRulesetPatch", + parameters: _models.DnsForwardingRulesetPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsForwardingRuleset"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsForwardingRuleset"]] + ) -> Optional[_models.DnsForwardingRuleset]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsForwardingRuleset]] _json = self._serialize.body(parameters, 'DnsForwardingRulesetPatch') @@ -491,15 +526,22 @@ def _update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -515,7 +557,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace @@ -523,10 +565,10 @@ def begin_update( self, resource_group_name: str, dns_forwarding_ruleset_name: str, - parameters: "_models.DnsForwardingRulesetPatch", + parameters: _models.DnsForwardingRulesetPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.DnsForwardingRuleset"]: + ) -> LROPoller[_models.DnsForwardingRuleset]: """Updates a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -534,10 +576,10 @@ def begin_update( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.DnsForwardingRulesetPatch + :type parameters: ~azure.mgmt.dnsresolver.models.DnsForwardingRulesetPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -549,40 +591,51 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either DnsForwardingRuleset or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsForwardingRuleset] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsForwardingRuleset] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsForwardingRuleset', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -591,36 +644,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -630,11 +694,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -650,7 +714,7 @@ def begin_delete( :type dns_forwarding_ruleset_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -664,19 +728,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -686,8 +757,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -696,10 +773,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace def get( @@ -707,7 +783,7 @@ def get( resource_group_name: str, dns_forwarding_ruleset_name: str, **kwargs: Any - ) -> "_models.DnsForwardingRuleset": + ) -> _models.DnsForwardingRuleset: """Gets a DNS forwarding ruleset properties. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -716,26 +792,38 @@ def get( :type dns_forwarding_ruleset_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsForwardingRuleset, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.DnsForwardingRuleset + :rtype: ~azure.mgmt.dnsresolver.models.DnsForwardingRuleset :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRuleset"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRuleset] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -749,7 +837,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}"} # type: ignore @distributed_trace @@ -758,48 +846,59 @@ def list_by_resource_group( resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DnsForwardingRulesetListResult"]: + ) -> Iterable[_models.DnsForwardingRulesetListResult]: """Lists DNS forwarding rulesets within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +912,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -826,51 +929,62 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets"} # type: ignore @distributed_trace def list( self, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DnsForwardingRulesetListResult"]: + ) -> Iterable[_models.DnsForwardingRulesetListResult]: """Lists DNS forwarding rulesets in all resource groups of a subscription. :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsForwardingRulesetListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -884,7 +998,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,7 +1015,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsForwardingRulesets"} # type: ignore @distributed_trace def list_by_virtual_network( @@ -906,7 +1024,7 @@ def list_by_virtual_network( virtual_network_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.VirtualNetworkDnsForwardingRulesetListResult"]: + ) -> Iterable[_models.VirtualNetworkDnsForwardingRulesetListResult]: """Lists DNS forwarding ruleset resource IDs attached to a virtual network. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -914,20 +1032,25 @@ def list_by_virtual_network( :param virtual_network_name: The name of the virtual network. :type virtual_network_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworkDnsForwardingRulesetListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.VirtualNetworkDnsForwardingRulesetListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkDnsForwardingRulesetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkDnsForwardingRulesetListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkDnsForwardingRulesetListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -935,11 +1058,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=self.list_by_virtual_network.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -947,11 +1073,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -965,7 +1094,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -978,4 +1111,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets'} # type: ignore + list_by_virtual_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsForwardingRulesets"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py index cd7d2ca91626..3611c1e0c5b4 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_dns_resolvers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,45 +34,46 @@ def build_create_or_update_request_initial( resource_group_name: str, dns_resolver_name: str, *, - json: JSONType = None, + json: Optional[_models.DnsResolver] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,42 +85,43 @@ def build_update_request_initial( resource_group_name: str, dns_resolver_name: str, *, - json: JSONType = None, + json: Optional[_models.DnsResolverPatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -134,33 +136,35 @@ def build_delete_request_initial( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -171,31 +175,33 @@ def build_get_request( dns_resolver_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -207,32 +213,34 @@ def build_list_by_resource_group_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -243,31 +251,33 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -280,74 +290,78 @@ def build_list_by_virtual_network_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DnsResolversOperations(object): - """DnsResolversOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DnsResolversOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`dns_resolvers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolver", + parameters: _models.DnsResolver, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsResolver"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + ) -> Optional[_models.DnsResolver]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsResolver]] _json = self._serialize.body(parameters, 'DnsResolver') @@ -355,16 +369,23 @@ def _create_or_update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -383,7 +404,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace @@ -391,11 +412,11 @@ def begin_create_or_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolver", + parameters: _models.DnsResolver, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.DnsResolver"]: + ) -> LROPoller[_models.DnsResolver]: """Creates or updates a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -403,13 +424,13 @@ def begin_create_or_update( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.DnsResolver + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolver :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -421,40 +442,52 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either DnsResolver or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsResolver] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsResolver', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -463,26 +496,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore def _update_initial( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolverPatch", + parameters: _models.DnsResolverPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.DnsResolver"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DnsResolver"]] + ) -> Optional[_models.DnsResolver]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DnsResolver]] _json = self._serialize.body(parameters, 'DnsResolverPatch') @@ -490,15 +526,22 @@ def _update_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -514,7 +557,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace @@ -522,10 +565,10 @@ def begin_update( self, resource_group_name: str, dns_resolver_name: str, - parameters: "_models.DnsResolverPatch", + parameters: _models.DnsResolverPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.DnsResolver"]: + ) -> LROPoller[_models.DnsResolver]: """Updates a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -533,10 +576,10 @@ def begin_update( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.DnsResolverPatch + :type parameters: ~azure.mgmt.dnsresolver.models.DnsResolverPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -548,39 +591,51 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either DnsResolver or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.DnsResolver] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.DnsResolver] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('DnsResolver', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -589,36 +644,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -628,11 +694,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -647,7 +713,7 @@ def begin_delete( :type dns_resolver_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -661,19 +727,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -683,8 +756,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -693,10 +772,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace def get( @@ -704,7 +782,7 @@ def get( resource_group_name: str, dns_resolver_name: str, **kwargs: Any - ) -> "_models.DnsResolver": + ) -> _models.DnsResolver: """Gets properties of a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -713,26 +791,38 @@ def get( :type dns_resolver_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DnsResolver, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.DnsResolver + :rtype: ~azure.mgmt.dnsresolver.models.DnsResolver :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolver"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolver] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,7 +836,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}"} # type: ignore @distributed_trace @@ -755,48 +845,58 @@ def list_by_resource_group( resource_group_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DnsResolverListResult"]: + ) -> Iterable[_models.DnsResolverListResult]: """Lists DNS resolvers within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsResolverListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolverListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -810,7 +910,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,51 +927,61 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers"} # type: ignore @distributed_trace def list( self, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DnsResolverListResult"]: + ) -> Iterable[_models.DnsResolverListResult]: """Lists DNS resolvers in all resource groups of a subscription. :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DnsResolverListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.DnsResolverListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.DnsResolverListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DnsResolverListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DnsResolverListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -881,7 +995,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -894,7 +1012,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnsResolvers"} # type: ignore @distributed_trace def list_by_virtual_network( @@ -903,7 +1021,7 @@ def list_by_virtual_network( virtual_network_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubResourceListResult"]: + ) -> Iterable[_models.SubResourceListResult]: """Lists DNS resolver resource IDs linked to a virtual network. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -911,20 +1029,24 @@ def list_by_virtual_network( :param virtual_network_name: The name of the virtual network. :type virtual_network_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubResourceListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.SubResourceListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.SubResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubResourceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -932,11 +1054,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=self.list_by_virtual_network.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -944,11 +1069,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -962,7 +1090,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -975,4 +1107,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers'} # type: ignore + list_by_virtual_network.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/listDnsResolvers"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py index 99badcbf9bf6..30aa87be73de 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_forwarding_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,18 +33,21 @@ def build_create_or_update_request( dns_forwarding_ruleset_name: str, forwarding_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ForwardingRule] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -52,27 +55,25 @@ def build_create_or_update_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -85,17 +86,20 @@ def build_update_request( dns_forwarding_ruleset_name: str, forwarding_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ForwardingRulePatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -103,25 +107,23 @@ def build_update_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -137,10 +139,14 @@ def build_delete_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -148,23 +154,21 @@ def build_delete_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -176,10 +180,14 @@ def build_get_request( forwarding_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -187,21 +195,19 @@ def build_get_request( "forwardingRuleName": _SERIALIZER.url("forwarding_rule_name", forwarding_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -214,57 +220,57 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ForwardingRulesOperations(object): - """ForwardingRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ForwardingRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`forwarding_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( @@ -272,11 +278,11 @@ def create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: "_models.ForwardingRule", + parameters: _models.ForwardingRule, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Creates or updates a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -286,26 +292,30 @@ def create_or_update( :param forwarding_rule_name: The name of the forwarding rule. :type forwarding_rule_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.ForwardingRule + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRule :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] _json = self._serialize.body(parameters, 'ForwardingRule') @@ -314,16 +324,23 @@ def create_or_update( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -341,7 +358,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace @@ -350,10 +367,10 @@ def update( resource_group_name: str, dns_forwarding_ruleset_name: str, forwarding_rule_name: str, - parameters: "_models.ForwardingRulePatch", + parameters: _models.ForwardingRulePatch, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Updates a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -363,23 +380,27 @@ def update( :param forwarding_rule_name: The name of the forwarding rule. :type forwarding_rule_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.ForwardingRulePatch + :type parameters: ~azure.mgmt.dnsresolver.models.ForwardingRulePatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] _json = self._serialize.body(parameters, 'ForwardingRulePatch') @@ -388,15 +409,22 @@ def update( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,11 +438,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -433,18 +461,23 @@ def delete( :type forwarding_rule_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -452,13 +485,20 @@ def delete( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -468,7 +508,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace @@ -478,7 +518,7 @@ def get( dns_forwarding_ruleset_name: str, forwarding_rule_name: str, **kwargs: Any - ) -> "_models.ForwardingRule": + ) -> _models.ForwardingRule: """Gets properties of a forwarding rule in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -489,14 +529,19 @@ def get( :type forwarding_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ForwardingRule, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.ForwardingRule + :rtype: ~azure.mgmt.dnsresolver.models.ForwardingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRule] request = build_get_request( @@ -504,12 +549,19 @@ def get( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, forwarding_rule_name=forwarding_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -523,7 +575,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules/{forwardingRuleName}"} # type: ignore @distributed_trace @@ -533,7 +585,7 @@ def list( dns_forwarding_ruleset_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ForwardingRuleListResult"]: + ) -> Iterable[_models.ForwardingRuleListResult]: """Lists forwarding rules in a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -541,20 +593,24 @@ def list( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ForwardingRuleListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.ForwardingRuleListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.ForwardingRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForwardingRuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ForwardingRuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -562,11 +618,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -574,11 +633,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,7 +654,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -605,4 +671,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/forwardingRules"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py index 089454583f18..5b76d51b9ad4 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_inbound_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,18 +35,21 @@ def build_create_or_update_request_initial( dns_resolver_name: str, inbound_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.InboundEndpoint] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -54,27 +57,25 @@ def build_create_or_update_request_initial( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,17 +88,20 @@ def build_update_request_initial( dns_resolver_name: str, inbound_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.InboundEndpointPatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -105,25 +109,23 @@ def build_update_request_initial( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -139,10 +141,14 @@ def build_delete_request_initial( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -150,23 +156,21 @@ def build_delete_request_initial( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -178,10 +182,14 @@ def build_get_request( inbound_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -189,21 +197,19 @@ def build_get_request( "inboundEndpointName": _SERIALIZER.url("inbound_endpoint_name", inbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -216,75 +222,79 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class InboundEndpointsOperations(object): - """InboundEndpointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class InboundEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`inbound_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpoint", + parameters: _models.InboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.InboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + ) -> Optional[_models.InboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.InboundEndpoint]] _json = self._serialize.body(parameters, 'InboundEndpoint') @@ -293,16 +303,23 @@ def _create_or_update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -321,7 +338,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace @@ -330,11 +347,11 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpoint", + parameters: _models.InboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.InboundEndpoint"]: + ) -> LROPoller[_models.InboundEndpoint]: """Creates or updates an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -344,13 +361,13 @@ def begin_create_or_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.InboundEndpoint + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpoint :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -362,41 +379,53 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either InboundEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('InboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -405,27 +434,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore def _update_initial( self, resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpointPatch", + parameters: _models.InboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.InboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InboundEndpoint"]] + ) -> Optional[_models.InboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.InboundEndpoint]] _json = self._serialize.body(parameters, 'InboundEndpointPatch') @@ -434,15 +466,22 @@ def _update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -458,7 +497,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace @@ -467,10 +506,10 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, inbound_endpoint_name: str, - parameters: "_models.InboundEndpointPatch", + parameters: _models.InboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.InboundEndpoint"]: + ) -> LROPoller[_models.InboundEndpoint]: """Updates an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -480,10 +519,10 @@ def begin_update( :param inbound_endpoint_name: The name of the inbound endpoint for the DNS resolver. :type inbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.InboundEndpointPatch + :type parameters: ~azure.mgmt.dnsresolver.models.InboundEndpointPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -495,40 +534,52 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either InboundEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.InboundEndpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.InboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('InboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -537,12 +588,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -550,11 +600,16 @@ def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -562,13 +617,20 @@ def _delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -578,11 +640,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -600,7 +662,7 @@ def begin_delete( :type inbound_endpoint_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -614,20 +676,27 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -637,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -647,10 +722,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace def get( @@ -659,7 +733,7 @@ def get( dns_resolver_name: str, inbound_endpoint_name: str, **kwargs: Any - ) -> "_models.InboundEndpoint": + ) -> _models.InboundEndpoint: """Gets properties of an inbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -670,14 +744,19 @@ def get( :type inbound_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: InboundEndpoint, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.InboundEndpoint + :rtype: ~azure.mgmt.dnsresolver.models.InboundEndpoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpoint] request = build_get_request( @@ -685,12 +764,19 @@ def get( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, inbound_endpoint_name=inbound_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,7 +790,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints/{inboundEndpointName}"} # type: ignore @distributed_trace @@ -714,7 +800,7 @@ def list( dns_resolver_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.InboundEndpointListResult"]: + ) -> Iterable[_models.InboundEndpointListResult]: """Lists inbound endpoints for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -722,20 +808,24 @@ def list( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either InboundEndpointListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.InboundEndpointListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.InboundEndpointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InboundEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InboundEndpointListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -743,11 +833,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -755,11 +848,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -773,7 +869,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,4 +886,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/inboundEndpoints"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py index b5bc0e76e761..d9f7a412bc52 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_outbound_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,18 +35,21 @@ def build_create_or_update_request_initial( dns_resolver_name: str, outbound_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.OutboundEndpoint] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -54,27 +57,25 @@ def build_create_or_update_request_initial( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,17 +88,20 @@ def build_update_request_initial( dns_resolver_name: str, outbound_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.OutboundEndpointPatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -105,25 +109,23 @@ def build_update_request_initial( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -139,10 +141,14 @@ def build_delete_request_initial( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -150,23 +156,21 @@ def build_delete_request_initial( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -178,10 +182,14 @@ def build_get_request( outbound_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -189,21 +197,19 @@ def build_get_request( "outboundEndpointName": _SERIALIZER.url("outbound_endpoint_name", outbound_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -216,75 +222,79 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsResolverName": _SERIALIZER.url("dns_resolver_name", dns_resolver_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class OutboundEndpointsOperations(object): - """OutboundEndpointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OutboundEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`outbound_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpoint", + parameters: _models.OutboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.OutboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + ) -> Optional[_models.OutboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OutboundEndpoint]] _json = self._serialize.body(parameters, 'OutboundEndpoint') @@ -293,16 +303,23 @@ def _create_or_update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -321,7 +338,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace @@ -330,11 +347,11 @@ def begin_create_or_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpoint", + parameters: _models.OutboundEndpoint, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.OutboundEndpoint"]: + ) -> LROPoller[_models.OutboundEndpoint]: """Creates or updates an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -344,13 +361,13 @@ def begin_create_or_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.OutboundEndpoint + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -362,41 +379,53 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either OutboundEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('OutboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -405,27 +434,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore def _update_initial( self, resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpointPatch", + parameters: _models.OutboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.OutboundEndpoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OutboundEndpoint"]] + ) -> Optional[_models.OutboundEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OutboundEndpoint]] _json = self._serialize.body(parameters, 'OutboundEndpointPatch') @@ -434,15 +466,22 @@ def _update_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -458,7 +497,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace @@ -467,10 +506,10 @@ def begin_update( resource_group_name: str, dns_resolver_name: str, outbound_endpoint_name: str, - parameters: "_models.OutboundEndpointPatch", + parameters: _models.OutboundEndpointPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.OutboundEndpoint"]: + ) -> LROPoller[_models.OutboundEndpoint]: """Updates an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -480,10 +519,10 @@ def begin_update( :param outbound_endpoint_name: The name of the outbound endpoint for the DNS resolver. :type outbound_endpoint_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.OutboundEndpointPatch + :type parameters: ~azure.mgmt.dnsresolver.models.OutboundEndpointPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -495,40 +534,52 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either OutboundEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.OutboundEndpoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.OutboundEndpoint] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('OutboundEndpoint', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -537,12 +588,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -550,11 +600,16 @@ def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -562,13 +617,20 @@ def _delete_initial( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -578,11 +640,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_resolver_name: str, @@ -600,7 +662,7 @@ def begin_delete( :type outbound_endpoint_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -614,20 +676,27 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -637,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -647,10 +722,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace def get( @@ -659,7 +733,7 @@ def get( dns_resolver_name: str, outbound_endpoint_name: str, **kwargs: Any - ) -> "_models.OutboundEndpoint": + ) -> _models.OutboundEndpoint: """Gets properties of an outbound endpoint for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -670,14 +744,19 @@ def get( :type outbound_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OutboundEndpoint, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.OutboundEndpoint + :rtype: ~azure.mgmt.dnsresolver.models.OutboundEndpoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpoint] request = build_get_request( @@ -685,12 +764,19 @@ def get( resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, outbound_endpoint_name=outbound_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -704,7 +790,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints/{outboundEndpointName}"} # type: ignore @distributed_trace @@ -714,7 +800,7 @@ def list( dns_resolver_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.OutboundEndpointListResult"]: + ) -> Iterable[_models.OutboundEndpointListResult]: """Lists outbound endpoints for a DNS resolver. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -722,20 +808,24 @@ def list( :param dns_resolver_name: The name of the DNS resolver. :type dns_resolver_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEndpointListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.OutboundEndpointListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.OutboundEndpointListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEndpointListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -743,11 +833,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -755,11 +848,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_resolver_name=dns_resolver_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -773,7 +869,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,4 +886,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsResolvers/{dnsResolverName}/outboundEndpoints"} # type: ignore diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_patch.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py index 3354a7b1f9bf..cc2500479c7e 100644 --- a/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py +++ b/sdk/dnsresolver/azure-mgmt-dnsresolver/azure/mgmt/dnsresolver/operations/_virtual_network_links_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,18 +35,21 @@ def build_create_or_update_request_initial( dns_forwarding_ruleset_name: str, virtual_network_link_name: str, *, - json: JSONType = None, + json: Optional[_models.VirtualNetworkLink] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -54,27 +57,25 @@ def build_create_or_update_request_initial( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,17 +88,20 @@ def build_update_request_initial( dns_forwarding_ruleset_name: str, virtual_network_link_name: str, *, - json: JSONType = None, + json: Optional[_models.VirtualNetworkLinkPatch] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-04-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -105,25 +109,23 @@ def build_update_request_initial( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -139,10 +141,14 @@ def build_delete_request_initial( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -150,23 +156,21 @@ def build_delete_request_initial( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -178,10 +182,14 @@ def build_get_request( virtual_network_link_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), @@ -189,21 +197,19 @@ def build_get_request( "virtualNetworkLinkName": _SERIALIZER.url("virtual_network_link_name", virtual_network_link_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -216,75 +222,79 @@ def build_list_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-04-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "dnsForwardingRulesetName": _SERIALIZER.url("dns_forwarding_ruleset_name", dns_forwarding_ruleset_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class VirtualNetworkLinksOperations(object): - """VirtualNetworkLinksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualNetworkLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~dns_resolver_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.dnsresolver.DnsResolverManagementClient`'s + :attr:`virtual_network_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLink", + parameters: _models.VirtualNetworkLink, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.VirtualNetworkLink"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + ) -> Optional[_models.VirtualNetworkLink]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualNetworkLink]] _json = self._serialize.body(parameters, 'VirtualNetworkLink') @@ -293,16 +303,23 @@ def _create_or_update_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, if_none_match=if_none_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -321,7 +338,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace @@ -330,11 +347,11 @@ def begin_create_or_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLink", + parameters: _models.VirtualNetworkLink, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.VirtualNetworkLink"]: + ) -> LROPoller[_models.VirtualNetworkLink]: """Creates or updates a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -344,13 +361,13 @@ def begin_create_or_update( :param virtual_network_link_name: The name of the virtual network link. :type virtual_network_link_name: str :param parameters: Parameters supplied to the CreateOrUpdate operation. - :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLink + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new resource to be created, but to prevent updating - an existing resource. Other values will be ignored. + an existing resource. Other values will be ignored. Default value is None. :type if_none_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -362,42 +379,53 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either VirtualNetworkLink or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -406,27 +434,30 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore def _update_initial( self, resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLinkPatch", + parameters: _models.VirtualNetworkLinkPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.VirtualNetworkLink"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualNetworkLink"]] + ) -> Optional[_models.VirtualNetworkLink]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualNetworkLink]] _json = self._serialize.body(parameters, 'VirtualNetworkLinkPatch') @@ -435,15 +466,22 @@ def _update_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -459,7 +497,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace @@ -468,10 +506,10 @@ def begin_update( resource_group_name: str, dns_forwarding_ruleset_name: str, virtual_network_link_name: str, - parameters: "_models.VirtualNetworkLinkPatch", + parameters: _models.VirtualNetworkLinkPatch, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.VirtualNetworkLink"]: + ) -> LROPoller[_models.VirtualNetworkLink]: """Updates a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -481,10 +519,10 @@ def begin_update( :param virtual_network_link_name: The name of the virtual network link. :type virtual_network_link_name: str :param parameters: Parameters supplied to the Update operation. - :type parameters: ~dns_resolver_management_client.models.VirtualNetworkLinkPatch + :type parameters: ~azure.mgmt.dnsresolver.models.VirtualNetworkLinkPatch :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -496,41 +534,52 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either VirtualNetworkLink or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~dns_resolver_management_client.models.VirtualNetworkLink] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dnsresolver.models.VirtualNetworkLink] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetworkLink', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -539,12 +588,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -552,11 +600,16 @@ def _delete_initial( if_match: Optional[str] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -564,13 +617,20 @@ def _delete_initial( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, if_match=if_match, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -580,11 +640,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, dns_forwarding_ruleset_name: str, @@ -603,7 +663,7 @@ def begin_delete( :type virtual_network_link_name: str :param if_match: ETag of the resource. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent - changes. + changes. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -617,20 +677,27 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 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( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, if_match=if_match, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -640,8 +707,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -650,10 +723,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace def get( @@ -662,7 +734,7 @@ def get( dns_forwarding_ruleset_name: str, virtual_network_link_name: str, **kwargs: Any - ) -> "_models.VirtualNetworkLink": + ) -> _models.VirtualNetworkLink: """Gets properties of a virtual network link to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -673,14 +745,19 @@ def get( :type virtual_network_link_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualNetworkLink, or the result of cls(response) - :rtype: ~dns_resolver_management_client.models.VirtualNetworkLink + :rtype: ~azure.mgmt.dnsresolver.models.VirtualNetworkLink :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLink"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLink] request = build_get_request( @@ -688,12 +765,19 @@ def get( resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, virtual_network_link_name=virtual_network_link_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,7 +791,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks/{virtualNetworkLinkName}"} # type: ignore @distributed_trace @@ -717,7 +801,7 @@ def list( dns_forwarding_ruleset_name: str, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.VirtualNetworkLinkListResult"]: + ) -> Iterable[_models.VirtualNetworkLinkListResult]: """Lists virtual network links to a DNS forwarding ruleset. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -725,20 +809,25 @@ def list( :param dns_forwarding_ruleset_name: The name of the DNS forwarding ruleset. :type dns_forwarding_ruleset_name: str :param top: The maximum number of results to return. If not specified, returns up to 100 - results. + results. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworkLinkListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~dns_resolver_management_client.models.VirtualNetworkLinkListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.dnsresolver.models.VirtualNetworkLinkListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkLinkListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkLinkListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -746,11 +835,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -758,11 +850,14 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, dns_forwarding_ruleset_name=dns_forwarding_ruleset_name, + api_version=api_version, top=top, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -776,7 +871,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -789,4 +888,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsForwardingRulesets/{dnsForwardingRulesetName}/virtualNetworkLinks"} # type: ignore