diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json b/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json index 1b02f1433a1c..808ea4e5072f 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/_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": "a1a224b54f05debfa94fd19477ed820c64f0f9fc", + "commit": "63f4e39c20223c20941614e776d33e699c3e2777", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/redisenterprise/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/redisenterprise/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/redisenterprise/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/__init__.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/__init__.py index f4c9229545d9..1d9e64377e53 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/__init__.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/__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__ = ['RedisEnterpriseManagementClient'] +__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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py index 75bb197bce7a..cddf5ac9e712 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class RedisEnterpriseManagementClientConfiguration(Configuration): +class RedisEnterpriseManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for RedisEnterpriseManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class RedisEnterpriseManagementClientConfiguration(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-01-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(RedisEnterpriseManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-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 = "2022-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-redisenterprise/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_metadata.json b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_metadata.json deleted file mode 100644 index 8f6746c33b58..000000000000 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "chosen_version": "2022-01-01", - "total_api_version_list": ["2022-01-01"], - "client": { - "name": "RedisEnterpriseManagementClient", - "filename": "_redis_enterprise_management_client", - "description": "REST API for managing Redis Enterprise resources in Azure.", - "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\": [\"RedisEnterpriseManagementClientConfiguration\"]}}, \"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\": [\"RedisEnterpriseManagementClientConfiguration\"]}}, \"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": { - "operations": "Operations", - "operations_status": "OperationsStatusOperations", - "redis_enterprise": "RedisEnterpriseOperations", - "databases": "DatabasesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "private_link_resources": "PrivateLinkResourcesOperations" - } -} \ No newline at end of file diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_redis_enterprise_management_client.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_redis_enterprise_management_client.py index b5f7880b1308..22873d51adeb 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_redis_enterprise_management_client.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_redis_enterprise_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 RedisEnterpriseManagementClientConfiguration @@ -42,8 +43,11 @@ class RedisEnterpriseManagementClient: :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-01-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. """ @@ -62,17 +66,29 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.operations_status = OperationsStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.redis_enterprise = RedisEnterpriseOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_status = OperationsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.redis_enterprise = RedisEnterpriseOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.databases = DatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + 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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/__init__.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/__init__.py index d006e74d1f3c..071f611a5e99 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/__init__.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._redis_enterprise_management_client import RedisEnterpriseManagementClient + +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__ = ['RedisEnterpriseManagementClient'] +__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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_configuration.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_configuration.py index 72e9c15e4574..66a16ddcf6a0 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_configuration.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class RedisEnterpriseManagementClientConfiguration(Configuration): +class RedisEnterpriseManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for RedisEnterpriseManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class RedisEnterpriseManagementClientConfiguration(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-01-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(RedisEnterpriseManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-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 = "2022-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-redisenterprise/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_redis_enterprise_management_client.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_redis_enterprise_management_client.py index a3e24ad06fff..7811dab1e768 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_redis_enterprise_management_client.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_redis_enterprise_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 RedisEnterpriseManagementClientConfiguration @@ -43,8 +44,11 @@ class RedisEnterpriseManagementClient: :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-01-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. """ @@ -63,12 +67,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.operations_status = OperationsStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.redis_enterprise = RedisEnterpriseOperations(self._client, self._config, self._serialize, self._deserialize) - self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_status = OperationsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.redis_enterprise = RedisEnterpriseOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.databases = DatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/__init__.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/__init__.py index 1847039b4da0..6bf07a5242a4 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/__init__.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/__init__.py @@ -13,6 +13,9 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +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__ = [ 'Operations', 'OperationsStatusOperations', @@ -21,3 +24,5 @@ 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', ] +__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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_databases_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_databases_operations.py index d8bea3d94736..31212f51701b 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_databases_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_databases_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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DatabasesOperations: - """DatabasesOperations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`databases` 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 def list_by_cluster( @@ -54,7 +52,7 @@ def list_by_cluster( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DatabaseList"]: + ) -> AsyncIterable[_models.DatabaseList]: """Gets all databases in the specified RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,11 +65,16 @@ def list_by_cluster( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.DatabaseList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseList] + 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: @@ -79,10 +82,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, template_url=self.list_by_cluster.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: @@ -90,10 +96,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, 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 @@ -107,7 +116,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]: @@ -121,23 +134,27 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases'} # type: ignore + list_by_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases"} # type: ignore async def _create_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: _models.Database, **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: 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-01-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.Database] _json = self._serialize.body(parameters, 'Database') @@ -146,14 +163,21 @@ async def _create_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_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]: @@ -171,7 +195,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async @@ -180,9 +204,9 @@ async def begin_create( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: _models.Database, **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Creates a database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -206,36 +230,48 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.Database] :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.Database"] + _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-01-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.Database] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -244,26 +280,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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DatabaseUpdate", + parameters: _models.DatabaseUpdate, **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> Optional[_models.Database]: 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-01-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.Database]] _json = self._serialize.body(parameters, 'DatabaseUpdate') @@ -272,14 +311,21 @@ async def _update_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, 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]: @@ -295,7 +341,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async @@ -304,9 +350,9 @@ async def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DatabaseUpdate", + parameters: _models.DatabaseUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Updates a database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -330,36 +376,48 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.Database] :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.Database"] + _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-01-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.Database] + 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, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -368,10 +426,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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async async def get( @@ -380,7 +437,7 @@ async def get( cluster_name: str, database_name: str, **kwargs: Any - ) -> "_models.Database": + ) -> _models.Database: """Gets information about a database in a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -394,11 +451,16 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.Database :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Database] request = build_get_request( @@ -406,12 +468,19 @@ async def get( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -426,21 +495,26 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, **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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -448,12 +522,19 @@ async def _delete_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -463,11 +544,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -494,19 +575,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-01-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, cluster_name=cluster_name, database_name=database_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -516,8 +604,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -526,10 +620,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.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async async def list_keys( @@ -538,7 +631,7 @@ async def list_keys( cluster_name: str, database_name: str, **kwargs: Any - ) -> "_models.AccessKeys": + ) -> _models.AccessKeys: """Retrieves the access keys for the RedisEnterprise database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -552,11 +645,16 @@ async def list_keys( :rtype: ~azure.mgmt.redisenterprise.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] request = build_list_keys_request( @@ -564,12 +662,19 @@ async def list_keys( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_keys.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]: @@ -584,7 +689,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys"} # type: ignore async def _regenerate_key_initial( @@ -592,16 +697,20 @@ async def _regenerate_key_initial( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: _models.RegenerateKeyParameters, **kwargs: Any - ) -> Optional["_models.AccessKeys"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessKeys"]] + ) -> Optional[_models.AccessKeys]: 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-01-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.AccessKeys]] _json = self._serialize.body(parameters, 'RegenerateKeyParameters') @@ -610,14 +719,21 @@ async def _regenerate_key_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._regenerate_key_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]: @@ -633,7 +749,7 @@ async def _regenerate_key_initial( return deserialized - _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey'} # type: ignore + _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -642,9 +758,9 @@ async def begin_regenerate_key( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: _models.RegenerateKeyParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessKeys"]: + ) -> AsyncLROPoller[_models.AccessKeys]: """Regenerates the RedisEnterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -668,36 +784,48 @@ async def begin_regenerate_key( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.AccessKeys] :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.AccessKeys"] + _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-01-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.AccessKeys] + 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._regenerate_key_initial( + raw_result = await self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -706,26 +834,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_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey'} # type: ignore + begin_regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey"} # type: ignore - async def _import_method_initial( + async def _import_method_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ImportClusterParameters", + parameters: _models.ImportClusterParameters, **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 {}) - 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-01-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[None] _json = self._serialize.body(parameters, 'ImportClusterParameters') @@ -734,14 +865,21 @@ async def _import_method_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._import_method_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]: @@ -751,16 +889,16 @@ async def _import_method_initial( if cls: return cls(pipeline_response, None, {}) - _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import'} # type: ignore + _import_method_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import"} # type: ignore @distributed_trace_async - async def begin_import_method( + async def begin_import_method( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ImportClusterParameters", + parameters: _models.ImportClusterParameters, **kwargs: Any ) -> AsyncLROPoller[None]: """Imports database files to target database. @@ -785,22 +923,29 @@ async def begin_import_method( :rtype: ~azure.core.polling.AsyncLROPoller[None] :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] + _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-01-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[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._import_method_initial( + raw_result = await self._import_method_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -810,8 +955,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -820,26 +971,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_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import'} # type: ignore + begin_import_method.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import"} # type: ignore - async def _export_initial( + async def _export_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ExportClusterParameters", + parameters: _models.ExportClusterParameters, **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 {}) - 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-01-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[None] _json = self._serialize.body(parameters, 'ExportClusterParameters') @@ -848,14 +1002,21 @@ async def _export_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._export_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]: @@ -865,16 +1026,16 @@ async def _export_initial( if cls: return cls(pipeline_response, None, {}) - _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export'} # type: ignore + _export_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export"} # type: ignore @distributed_trace_async - async def begin_export( + async def begin_export( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ExportClusterParameters", + parameters: _models.ExportClusterParameters, **kwargs: Any ) -> AsyncLROPoller[None]: """Exports a database file from target database. @@ -899,22 +1060,29 @@ async def begin_export( :rtype: ~azure.core.polling.AsyncLROPoller[None] :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] + _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-01-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[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._export_initial( + raw_result = await self._export_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -924,8 +1092,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -934,26 +1108,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_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export'} # type: ignore + begin_export.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export"} # type: ignore - async def _force_unlink_initial( + async def _force_unlink_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ForceUnlinkParameters", + parameters: _models.ForceUnlinkParameters, **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 = 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-01-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[None] _json = self._serialize.body(parameters, 'ForceUnlinkParameters') @@ -962,14 +1139,21 @@ async def _force_unlink_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._force_unlink_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]: @@ -979,16 +1163,16 @@ async def _force_unlink_initial( if cls: return cls(pipeline_response, None, {}) - _force_unlink_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink'} # type: ignore + _force_unlink_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink"} # type: ignore @distributed_trace_async - async def begin_force_unlink( + async def begin_force_unlink( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ForceUnlinkParameters", + parameters: _models.ForceUnlinkParameters, **kwargs: Any ) -> AsyncLROPoller[None]: """Forcibly removes the link to the specified database resource. @@ -1013,22 +1197,29 @@ async def begin_force_unlink( :rtype: ~azure.core.polling.AsyncLROPoller[None] :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] + _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-01-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[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._force_unlink_initial( + raw_result = await self._force_unlink_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1038,8 +1229,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1048,7 +1245,6 @@ 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_force_unlink.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink'} # type: ignore + begin_force_unlink.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations.py index 2491c2756c9e..9ee4b6a225b6 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_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 -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 @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`operations` 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 def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available REST API operations of the Microsoft.Cache provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + 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( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, 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 @@ -93,7 +101,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]: @@ -107,4 +119,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Cache/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Cache/operations"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations_status_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations_status_operations.py index 1db6b3b44bfe..818391ac82c2 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations_status_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # 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, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest 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 @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OperationsStatusOperations: - """OperationsStatusOperations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`operations_status` 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 get( @@ -50,7 +48,7 @@ async def get( location: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Gets the status of operation. :param location: The region the operation is in. @@ -62,23 +60,35 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -93,5 +103,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_patch.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_endpoint_connections_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_endpoint_connections_operations.py index 21375bb140ac..56028908810e 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_endpoint_connections_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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`private_endpoint_connections` 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 def list( @@ -54,7 +52,7 @@ def list( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """Lists all the private endpoint connections associated with the RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + 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: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -108,7 +117,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]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -146,11 +159,16 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -158,12 +176,19 @@ async def get( cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -178,7 +203,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _put_initial( @@ -186,16 +211,20 @@ async def _put_initial( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: 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-01-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -204,14 +233,21 @@ async def _put_initial( cluster_name=cluster_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._put_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 [201]: @@ -225,7 +261,7 @@ async def _put_initial( return deserialized - _put_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -234,9 +270,9 @@ async def begin_put( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Updates the state of the specified private endpoint connection associated with the RedisEnterprise cluster. @@ -263,36 +299,48 @@ async def begin_put( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.PrivateEndpointConnection] :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.PrivateEndpointConnection"] + _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-01-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.PrivateEndpointConnection] + 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._put_initial( + raw_result = await self._put_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + 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('PrivateEndpointConnection', 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( @@ -301,13 +349,12 @@ 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_put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -328,11 +375,16 @@ async def delete( :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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -340,12 +392,19 @@ async def delete( cluster_name=cluster_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -356,5 +415,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_link_resources_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_link_resources_operations.py index 2b933f0fdea1..5d0676ba6f24 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_link_resources_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_private_link_resources_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 -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 @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`private_link_resources` 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 def list_by_cluster( @@ -52,7 +49,7 @@ def list_by_cluster( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: """Gets the private link resources that need to be created for a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,11 +63,16 @@ def list_by_cluster( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + 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: @@ -78,10 +80,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_cluster.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: @@ -89,10 +94,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -106,7 +114,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]: @@ -120,4 +132,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources'} # type: ignore + list_by_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_redis_enterprise_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_redis_enterprise_operations.py index 4be3a9553813..3b410e596047 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_redis_enterprise_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_redis_enterprise_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,41 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RedisEnterpriseOperations: - """RedisEnterpriseOperations 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: ~azure.mgmt.redisenterprise.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.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`redis_enterprise` 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_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: 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-01-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.Cluster] _json = self._serialize.body(parameters, 'Cluster') @@ -69,14 +71,21 @@ async def _create_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_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]: @@ -94,7 +103,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace_async @@ -102,9 +111,9 @@ async def begin_create( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Creates or updates an existing (overwrite/recreate, with potential downtime) cache cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -126,35 +135,47 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.Cluster] :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.Cluster"] + _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-01-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.Cluster] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + 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('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -163,25 +184,28 @@ 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: _models.ClusterUpdate, **kwargs: Any - ) -> Optional["_models.Cluster"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cluster"]] + ) -> Optional[_models.Cluster]: 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-01-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.Cluster]] _json = self._serialize.body(parameters, 'ClusterUpdate') @@ -189,14 +213,21 @@ async def _update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, 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]: @@ -212,7 +243,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace_async @@ -220,9 +251,9 @@ async def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: _models.ClusterUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Updates an existing RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -244,35 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.Cluster] :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.Cluster"] + _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-01-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.Cluster] + 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, cluster_name=cluster_name, parameters=parameters, + 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('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -281,34 +324,45 @@ 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.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, **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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -318,11 +372,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -346,18 +400,25 @@ 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-01-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, cluster_name=cluster_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -367,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -377,10 +444,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.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace_async async def get( @@ -388,7 +454,7 @@ async def get( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Gets information about a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -400,23 +466,35 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.Cluster :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -431,7 +509,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace @@ -439,7 +517,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ClusterList"]: + ) -> AsyncIterable[_models.ClusterList]: """Lists all RedisEnterprise clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -449,31 +527,42 @@ def list_by_resource_group( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.ClusterList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterList] + 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( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -487,7 +576,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]: @@ -501,13 +594,13 @@ 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.Cache/redisEnterprise'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ClusterList"]: + ) -> AsyncIterable[_models.ClusterList]: """Gets all RedisEnterprise clusters in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -515,29 +608,40 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.ClusterList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterList] + 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, 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, 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 @@ -551,7 +655,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]: @@ -565,4 +673,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/__init__.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/__init__.py index a1a5640a839d..d496c21d46c6 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/__init__.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/__init__.py @@ -57,7 +57,9 @@ SkuName, TlsVersion, ) - +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__ = [ 'AccessKeys', 'Cluster', @@ -107,3 +109,5 @@ 'SkuName', 'TlsVersion', ] +__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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_models_py3.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_models_py3.py index ece9ac2e18a3..513393cad6a4 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_models_py3.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_models_py3.py @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._redis_enterprise_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessKeys(msrest.serialization.Model): @@ -163,16 +165,16 @@ class Cluster(TrackedResource): :ivar zones: The Availability Zones where this cluster will be deployed. :vartype zones: list[str] :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Possible values include: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", "1.2". :vartype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :ivar host_name: DNS name of the cluster endpoint. :vartype host_name: str - :ivar provisioning_state: Current provisioning status of the cluster. Possible values include: + :ivar provisioning_state: Current provisioning status of the cluster. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState - :ivar resource_state: Current resource status of the cluster. Possible values include: - "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", - "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled". + :ivar resource_state: Current resource status of the cluster. Known values are: "Running", + "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", + "EnableFailed", "Disabling", "DisableFailed", "Disabled". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState :ivar redis_version: Version of redis the cluster supports, e.g. '6'. :vartype redis_version: str @@ -215,10 +217,10 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - minimum_tls_version: Optional[Union[str, "TlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, **kwargs ): """ @@ -231,7 +233,7 @@ def __init__( :keyword zones: The Availability Zones where this cluster will be deployed. :paramtype zones: list[str] :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Possible values include: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", "1.2". :paramtype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion """ super(Cluster, self).__init__(tags=tags, location=location, **kwargs) @@ -268,7 +270,7 @@ class ClusterList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Cluster"]] = None, + value: Optional[List["_models.Cluster"]] = None, **kwargs ): """ @@ -290,16 +292,16 @@ class ClusterUpdate(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Possible values include: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", "1.2". :vartype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :ivar host_name: DNS name of the cluster endpoint. :vartype host_name: str - :ivar provisioning_state: Current provisioning status of the cluster. Possible values include: + :ivar provisioning_state: Current provisioning status of the cluster. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState - :ivar resource_state: Current resource status of the cluster. Possible values include: - "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", - "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled". + :ivar resource_state: Current resource status of the cluster. Known values are: "Running", + "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", + "EnableFailed", "Disabling", "DisableFailed", "Disabled". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState :ivar redis_version: Version of redis the cluster supports, e.g. '6'. :vartype redis_version: str @@ -331,9 +333,9 @@ class ClusterUpdate(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - minimum_tls_version: Optional[Union[str, "TlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, **kwargs ): """ @@ -342,7 +344,7 @@ def __init__( :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Possible values include: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", "1.2". :paramtype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion """ super(ClusterUpdate, self).__init__(**kwargs) @@ -406,23 +408,23 @@ class Database(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar client_protocol: Specifies whether redis clients can connect using TLS-encrypted or - plaintext redis protocols. Default is TLS-encrypted. Possible values include: "Encrypted", + plaintext redis protocols. Default is TLS-encrypted. Known values are: "Encrypted", "Plaintext". :vartype client_protocol: str or ~azure.mgmt.redisenterprise.models.Protocol :ivar port: TCP port of the database endpoint. Specified at create time. Defaults to an available port. :vartype port: int - :ivar provisioning_state: Current provisioning status of the database. Possible values include: + :ivar provisioning_state: Current provisioning status of the database. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState - :ivar resource_state: Current resource status of the database. Possible values include: - "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", - "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled". + :ivar resource_state: Current resource status of the database. Known values are: "Running", + "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", + "EnableFailed", "Disabling", "DisableFailed", "Disabled". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState :ivar clustering_policy: Clustering policy - default is OSSCluster. Specified at create time. - Possible values include: "EnterpriseCluster", "OSSCluster". + Known values are: "EnterpriseCluster", "OSSCluster". :vartype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy - :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Possible values include: + :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", "VolatileRandom", "NoEviction". :vartype eviction_policy: str or ~azure.mgmt.redisenterprise.models.EvictionPolicy @@ -462,29 +464,29 @@ class Database(ProxyResource): def __init__( self, *, - client_protocol: Optional[Union[str, "Protocol"]] = None, + client_protocol: Optional[Union[str, "_models.Protocol"]] = None, port: Optional[int] = None, - clustering_policy: Optional[Union[str, "ClusteringPolicy"]] = None, - eviction_policy: Optional[Union[str, "EvictionPolicy"]] = None, - persistence: Optional["Persistence"] = None, - modules: Optional[List["Module"]] = None, - geo_replication: Optional["DatabasePropertiesGeoReplication"] = None, + clustering_policy: Optional[Union[str, "_models.ClusteringPolicy"]] = None, + eviction_policy: Optional[Union[str, "_models.EvictionPolicy"]] = None, + persistence: Optional["_models.Persistence"] = None, + modules: Optional[List["_models.Module"]] = None, + geo_replication: Optional["_models.DatabasePropertiesGeoReplication"] = None, **kwargs ): """ :keyword client_protocol: Specifies whether redis clients can connect using TLS-encrypted or - plaintext redis protocols. Default is TLS-encrypted. Possible values include: "Encrypted", + plaintext redis protocols. Default is TLS-encrypted. Known values are: "Encrypted", "Plaintext". :paramtype client_protocol: str or ~azure.mgmt.redisenterprise.models.Protocol :keyword port: TCP port of the database endpoint. Specified at create time. Defaults to an available port. :paramtype port: int :keyword clustering_policy: Clustering policy - default is OSSCluster. Specified at create - time. Possible values include: "EnterpriseCluster", "OSSCluster". + time. Known values are: "EnterpriseCluster", "OSSCluster". :paramtype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy - :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Possible values - include: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", - "VolatileTTL", "VolatileRandom", "NoEviction". + :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: + "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", + "VolatileRandom", "NoEviction". :paramtype eviction_policy: str or ~azure.mgmt.redisenterprise.models.EvictionPolicy :keyword persistence: Persistence settings. :paramtype persistence: ~azure.mgmt.redisenterprise.models.Persistence @@ -530,7 +532,7 @@ class DatabaseList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Database"]] = None, + value: Optional[List["_models.Database"]] = None, **kwargs ): """ @@ -560,7 +562,7 @@ def __init__( self, *, group_nickname: Optional[str] = None, - linked_databases: Optional[List["LinkedDatabase"]] = None, + linked_databases: Optional[List["_models.LinkedDatabase"]] = None, **kwargs ): """ @@ -580,23 +582,23 @@ class DatabaseUpdate(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar client_protocol: Specifies whether redis clients can connect using TLS-encrypted or - plaintext redis protocols. Default is TLS-encrypted. Possible values include: "Encrypted", + plaintext redis protocols. Default is TLS-encrypted. Known values are: "Encrypted", "Plaintext". :vartype client_protocol: str or ~azure.mgmt.redisenterprise.models.Protocol :ivar port: TCP port of the database endpoint. Specified at create time. Defaults to an available port. :vartype port: int - :ivar provisioning_state: Current provisioning status of the database. Possible values include: + :ivar provisioning_state: Current provisioning status of the database. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState - :ivar resource_state: Current resource status of the database. Possible values include: - "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", - "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled". + :ivar resource_state: Current resource status of the database. Known values are: "Running", + "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", + "EnableFailed", "Disabling", "DisableFailed", "Disabled". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState :ivar clustering_policy: Clustering policy - default is OSSCluster. Specified at create time. - Possible values include: "EnterpriseCluster", "OSSCluster". + Known values are: "EnterpriseCluster", "OSSCluster". :vartype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy - :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Possible values include: + :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", "VolatileRandom", "NoEviction". :vartype eviction_policy: str or ~azure.mgmt.redisenterprise.models.EvictionPolicy @@ -630,29 +632,29 @@ class DatabaseUpdate(msrest.serialization.Model): def __init__( self, *, - client_protocol: Optional[Union[str, "Protocol"]] = None, + client_protocol: Optional[Union[str, "_models.Protocol"]] = None, port: Optional[int] = None, - clustering_policy: Optional[Union[str, "ClusteringPolicy"]] = None, - eviction_policy: Optional[Union[str, "EvictionPolicy"]] = None, - persistence: Optional["Persistence"] = None, - modules: Optional[List["Module"]] = None, - geo_replication: Optional["DatabasePropertiesGeoReplication"] = None, + clustering_policy: Optional[Union[str, "_models.ClusteringPolicy"]] = None, + eviction_policy: Optional[Union[str, "_models.EvictionPolicy"]] = None, + persistence: Optional["_models.Persistence"] = None, + modules: Optional[List["_models.Module"]] = None, + geo_replication: Optional["_models.DatabasePropertiesGeoReplication"] = None, **kwargs ): """ :keyword client_protocol: Specifies whether redis clients can connect using TLS-encrypted or - plaintext redis protocols. Default is TLS-encrypted. Possible values include: "Encrypted", + plaintext redis protocols. Default is TLS-encrypted. Known values are: "Encrypted", "Plaintext". :paramtype client_protocol: str or ~azure.mgmt.redisenterprise.models.Protocol :keyword port: TCP port of the database endpoint. Specified at create time. Defaults to an available port. :paramtype port: int :keyword clustering_policy: Clustering policy - default is OSSCluster. Specified at create - time. Possible values include: "EnterpriseCluster", "OSSCluster". + time. Known values are: "EnterpriseCluster", "OSSCluster". :paramtype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy - :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Possible values - include: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", - "VolatileTTL", "VolatileRandom", "NoEviction". + :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: + "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", + "VolatileRandom", "NoEviction". :paramtype eviction_policy: str or ~azure.mgmt.redisenterprise.models.EvictionPolicy :keyword persistence: Persistence settings. :paramtype persistence: ~azure.mgmt.redisenterprise.models.Persistence @@ -768,7 +770,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -879,8 +881,8 @@ class LinkedDatabase(msrest.serialization.Model): :ivar id: Resource ID of a database resource to link with this database. :vartype id: str - :ivar state: State of the link between the database resources. Possible values include: - "Linked", "Linking", "Unlinking", "LinkFailed", "UnlinkFailed". + :ivar state: State of the link between the database resources. Known values are: "Linked", + "Linking", "Unlinking", "LinkFailed", "UnlinkFailed". :vartype state: str or ~azure.mgmt.redisenterprise.models.LinkState """ @@ -969,11 +971,11 @@ class Operation(msrest.serialization.Model): :ivar display: Localized display information for this particular operation. :vartype display: ~azure.mgmt.redisenterprise.models.OperationDisplay :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", - "system", "user,system". + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". :vartype origin: str or ~azure.mgmt.redisenterprise.models.Origin :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. Known values are: "Internal". :vartype action_type: str or ~azure.mgmt.redisenterprise.models.ActionType """ @@ -995,7 +997,7 @@ class Operation(msrest.serialization.Model): def __init__( self, *, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -1122,7 +1124,7 @@ def __init__( start_time: Optional[str] = None, end_time: Optional[str] = None, status: Optional[str] = None, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): """ @@ -1155,11 +1157,11 @@ class Persistence(msrest.serialization.Model): :vartype aof_enabled: bool :ivar rdb_enabled: Sets whether RDB is enabled. :vartype rdb_enabled: bool - :ivar aof_frequency: Sets the frequency at which data is written to disk. Possible values - include: "1s", "always". + :ivar aof_frequency: Sets the frequency at which data is written to disk. Known values are: + "1s", "always". :vartype aof_frequency: str or ~azure.mgmt.redisenterprise.models.AofFrequency - :ivar rdb_frequency: Sets the frequency at which a snapshot of the database is created. - Possible values include: "1h", "6h", "12h". + :ivar rdb_frequency: Sets the frequency at which a snapshot of the database is created. Known + values are: "1h", "6h", "12h". :vartype rdb_frequency: str or ~azure.mgmt.redisenterprise.models.RdbFrequency """ @@ -1175,8 +1177,8 @@ def __init__( *, aof_enabled: Optional[bool] = None, rdb_enabled: Optional[bool] = None, - aof_frequency: Optional[Union[str, "AofFrequency"]] = None, - rdb_frequency: Optional[Union[str, "RdbFrequency"]] = None, + aof_frequency: Optional[Union[str, "_models.AofFrequency"]] = None, + rdb_frequency: Optional[Union[str, "_models.RdbFrequency"]] = None, **kwargs ): """ @@ -1184,11 +1186,11 @@ def __init__( :paramtype aof_enabled: bool :keyword rdb_enabled: Sets whether RDB is enabled. :paramtype rdb_enabled: bool - :keyword aof_frequency: Sets the frequency at which data is written to disk. Possible values - include: "1s", "always". + :keyword aof_frequency: Sets the frequency at which data is written to disk. Known values are: + "1s", "always". :paramtype aof_frequency: str or ~azure.mgmt.redisenterprise.models.AofFrequency :keyword rdb_frequency: Sets the frequency at which a snapshot of the database is created. - Possible values include: "1h", "6h", "12h". + Known values are: "1h", "6h", "12h". :paramtype rdb_frequency: str or ~azure.mgmt.redisenterprise.models.RdbFrequency """ super(Persistence, self).__init__(**kwargs) @@ -1245,7 +1247,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.redisenterprise.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.PrivateEndpointConnectionProvisioningState """ @@ -1269,8 +1271,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -1301,7 +1303,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -1380,7 +1382,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -1395,7 +1397,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.redisenterprise.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -1414,14 +1416,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.redisenterprise.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -1441,7 +1443,7 @@ class RegenerateKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. Which access key to regenerate. Possible values include: "Primary", + :ivar key_type: Required. Which access key to regenerate. Known values are: "Primary", "Secondary". :vartype key_type: str or ~azure.mgmt.redisenterprise.models.AccessKeyType """ @@ -1457,12 +1459,12 @@ class RegenerateKeyParameters(msrest.serialization.Model): def __init__( self, *, - key_type: Union[str, "AccessKeyType"], + key_type: Union[str, "_models.AccessKeyType"], **kwargs ): """ - :keyword key_type: Required. Which access key to regenerate. Possible values include: - "Primary", "Secondary". + :keyword key_type: Required. Which access key to regenerate. Known values are: "Primary", + "Secondary". :paramtype key_type: str or ~azure.mgmt.redisenterprise.models.AccessKeyType """ super(RegenerateKeyParameters, self).__init__(**kwargs) @@ -1475,7 +1477,7 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The type of RedisEnterprise cluster to deploy. Possible values: - (Enterprise_E10, EnterpriseFlash_F300 etc.). Possible values include: "Enterprise_E10", + (Enterprise_E10, EnterpriseFlash_F300 etc.). Known values are: "Enterprise_E10", "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "EnterpriseFlash_F300", "EnterpriseFlash_F700", "EnterpriseFlash_F1500". :vartype name: str or ~azure.mgmt.redisenterprise.models.SkuName @@ -1496,13 +1498,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], capacity: Optional[int] = None, **kwargs ): """ :keyword name: Required. The type of RedisEnterprise cluster to deploy. Possible values: - (Enterprise_E10, EnterpriseFlash_F300 etc.). Possible values include: "Enterprise_E10", + (Enterprise_E10, EnterpriseFlash_F300 etc.). Known values are: "Enterprise_E10", "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "EnterpriseFlash_F300", "EnterpriseFlash_F700", "EnterpriseFlash_F1500". :paramtype name: str or ~azure.mgmt.redisenterprise.models.SkuName diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_patch.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_redis_enterprise_management_client_enums.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_redis_enterprise_management_client_enums.py index e70b5ea171df..4be31eba1f36 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_redis_enterprise_management_client_enums.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/models/_redis_enterprise_management_client_enums.py @@ -7,38 +7,37 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Which access key to regenerate. """ PRIMARY = "Primary" SECONDARY = "Secondary" -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. """ INTERNAL = "Internal" -class AofFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AofFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets the frequency at which data is written to disk. """ ONE_S = "1s" ALWAYS = "always" -class ClusteringPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ClusteringPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Clustering policy - default is OSSCluster. Specified at create time. """ ENTERPRISE_CLUSTER = "EnterpriseCluster" OSS_CLUSTER = "OSSCluster" -class EvictionPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EvictionPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Redis eviction policy - default is VolatileLRU """ @@ -51,7 +50,7 @@ class EvictionPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): VOLATILE_RANDOM = "VolatileRandom" NO_EVICTION = "NoEviction" -class LinkState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinkState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the link between the database resources. """ @@ -61,7 +60,7 @@ class LinkState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LINK_FAILED = "LinkFailed" UNLINK_FAILED = "UnlinkFailed" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" """ @@ -70,7 +69,7 @@ class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM = "system" USER_SYSTEM = "user,system" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -79,7 +78,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -87,7 +86,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class Protocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Protocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is TLS-encrypted. """ @@ -95,7 +94,7 @@ class Protocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENCRYPTED = "Encrypted" PLAINTEXT = "Plaintext" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Current provisioning status """ @@ -106,7 +105,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" DELETING = "Deleting" -class RdbFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RdbFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets the frequency at which a snapshot of the database is created. """ @@ -114,7 +113,7 @@ class RdbFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SIX_H = "6h" TWELVE_H = "12h" -class ResourceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Current resource status """ @@ -131,7 +130,7 @@ class ResourceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLE_FAILED = "DisableFailed" DISABLED = "Disabled" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of RedisEnterprise cluster to deploy. Possible values: (Enterprise_E10, EnterpriseFlash_F300 etc.) """ @@ -144,7 +143,7 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENTERPRISE_FLASH_F700 = "EnterpriseFlash_F700" ENTERPRISE_FLASH_F1500 = "EnterpriseFlash_F1500" -class TlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The minimum TLS version for the cluster to support, e.g. '1.2' """ diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/__init__.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/__init__.py index 1847039b4da0..6bf07a5242a4 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/__init__.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/__init__.py @@ -13,6 +13,9 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +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__ = [ 'Operations', 'OperationsStatusOperations', @@ -21,3 +24,5 @@ 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', ] +__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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_databases_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_databases_operations.py index 0c672354aaf5..1d206715af2d 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_databases_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_databases_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,31 +35,33 @@ def build_list_by_cluster_request( cluster_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases") # 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), "clusterName": _SERIALIZER.url("cluster_name", cluster_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 ) @@ -70,16 +72,19 @@ def build_create_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Database] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -87,23 +92,21 @@ def build_create_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _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 @@ -116,16 +119,19 @@ def build_update_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DatabaseUpdate] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -133,23 +139,21 @@ def build_update_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _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 @@ -163,10 +167,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -174,21 +182,19 @@ def build_get_request( "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') # 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 ) @@ -200,10 +206,14 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -211,21 +221,19 @@ def build_delete_request_initial( "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') # 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="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -237,10 +245,14 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -248,21 +260,19 @@ def build_list_keys_request( "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') # 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 ) @@ -273,16 +283,19 @@ def build_regenerate_key_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RegenerateKeyParameters] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -290,23 +303,21 @@ def build_regenerate_key_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, '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, json=json, content=content, **kwargs @@ -319,16 +330,19 @@ def build_import_method_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImportClusterParameters] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -336,23 +350,21 @@ def build_import_method_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, '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, json=json, content=content, **kwargs @@ -365,16 +377,19 @@ def build_export_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ExportClusterParameters] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -382,23 +397,21 @@ def build_export_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, '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, json=json, content=content, **kwargs @@ -411,16 +424,19 @@ def build_force_unlink_request_initial( database_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ForceUnlinkParameters] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -428,49 +444,45 @@ def build_force_unlink_request_initial( "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, '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, json=json, content=content, **kwargs ) -class DatabasesOperations(object): - """DatabasesOperations 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 DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`databases` 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 list_by_cluster( @@ -478,7 +490,7 @@ def list_by_cluster( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Iterable["_models.DatabaseList"]: + ) -> Iterable[_models.DatabaseList]: """Gets all databases in the specified RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -490,11 +502,16 @@ def list_by_cluster( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.DatabaseList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseList] + 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: @@ -502,10 +519,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, template_url=self.list_by_cluster.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: @@ -513,10 +533,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + api_version=api_version, 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 @@ -530,7 +553,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]: @@ -544,23 +571,27 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases'} # type: ignore + list_by_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases"} # type: ignore def _create_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: _models.Database, **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: 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-01-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.Database] _json = self._serialize.body(parameters, 'Database') @@ -569,14 +600,21 @@ def _create_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_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]: @@ -594,7 +632,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace @@ -603,9 +641,9 @@ def begin_create( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: _models.Database, **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Creates a database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -628,36 +666,48 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.Database] :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.Database"] + _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-01-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.Database] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -666,26 +716,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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DatabaseUpdate", + parameters: _models.DatabaseUpdate, **kwargs: Any - ) -> Optional["_models.Database"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Database"]] + ) -> Optional[_models.Database]: 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-01-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.Database]] _json = self._serialize.body(parameters, 'DatabaseUpdate') @@ -694,14 +747,21 @@ def _update_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, 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]: @@ -717,7 +777,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace @@ -726,9 +786,9 @@ def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DatabaseUpdate", + parameters: _models.DatabaseUpdate, **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Updates a database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -751,36 +811,48 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.Database] :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.Database"] + _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-01-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.Database] + 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, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('Database', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -789,10 +861,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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace def get( @@ -801,7 +872,7 @@ def get( cluster_name: str, database_name: str, **kwargs: Any - ) -> "_models.Database": + ) -> _models.Database: """Gets information about a database in a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -815,11 +886,16 @@ def get( :rtype: ~azure.mgmt.redisenterprise.models.Database :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Database] request = build_get_request( @@ -827,12 +903,19 @@ def get( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -847,21 +930,26 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, **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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -869,12 +957,19 @@ def _delete_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -884,11 +979,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -915,19 +1010,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-01-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, cluster_name=cluster_name, database_name=database_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -937,8 +1039,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -947,10 +1055,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.Cache/redisEnterprise/{clusterName}/databases/{databaseName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace def list_keys( @@ -959,7 +1066,7 @@ def list_keys( cluster_name: str, database_name: str, **kwargs: Any - ) -> "_models.AccessKeys": + ) -> _models.AccessKeys: """Retrieves the access keys for the RedisEnterprise database. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -973,11 +1080,16 @@ def list_keys( :rtype: ~azure.mgmt.redisenterprise.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] request = build_list_keys_request( @@ -985,12 +1097,19 @@ def list_keys( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_keys.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]: @@ -1005,7 +1124,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys"} # type: ignore def _regenerate_key_initial( @@ -1013,16 +1132,20 @@ def _regenerate_key_initial( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: _models.RegenerateKeyParameters, **kwargs: Any - ) -> Optional["_models.AccessKeys"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessKeys"]] + ) -> Optional[_models.AccessKeys]: 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-01-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.AccessKeys]] _json = self._serialize.body(parameters, 'RegenerateKeyParameters') @@ -1031,14 +1154,21 @@ def _regenerate_key_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._regenerate_key_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]: @@ -1054,7 +1184,7 @@ def _regenerate_key_initial( return deserialized - _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey'} # type: ignore + _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey"} # type: ignore @distributed_trace @@ -1063,9 +1193,9 @@ def begin_regenerate_key( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: _models.RegenerateKeyParameters, **kwargs: Any - ) -> LROPoller["_models.AccessKeys"]: + ) -> LROPoller[_models.AccessKeys]: """Regenerates the RedisEnterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -1088,36 +1218,48 @@ def begin_regenerate_key( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.AccessKeys] :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.AccessKeys"] + _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-01-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.AccessKeys] + 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._regenerate_key_initial( + raw_result = self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + 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('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1126,26 +1268,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_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey'} # type: ignore + begin_regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey"} # type: ignore - def _import_method_initial( + def _import_method_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ImportClusterParameters", + parameters: _models.ImportClusterParameters, **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 = 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-01-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[None] _json = self._serialize.body(parameters, 'ImportClusterParameters') @@ -1154,14 +1299,21 @@ def _import_method_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._import_method_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]: @@ -1171,16 +1323,16 @@ def _import_method_initial( if cls: return cls(pipeline_response, None, {}) - _import_method_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import'} # type: ignore + _import_method_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import"} # type: ignore @distributed_trace - def begin_import_method( + def begin_import_method( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ImportClusterParameters", + parameters: _models.ImportClusterParameters, **kwargs: Any ) -> LROPoller[None]: """Imports database files to target database. @@ -1205,22 +1357,29 @@ def begin_import_method( :rtype: ~azure.core.polling.LROPoller[None] :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] + _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-01-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[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._import_method_initial( + raw_result = self._import_method_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1230,8 +1389,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1240,26 +1405,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_import_method.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import'} # type: ignore + begin_import_method.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import"} # type: ignore - def _export_initial( + def _export_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ExportClusterParameters", + parameters: _models.ExportClusterParameters, **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 = 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-01-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[None] _json = self._serialize.body(parameters, 'ExportClusterParameters') @@ -1268,14 +1436,21 @@ def _export_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._export_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]: @@ -1285,16 +1460,16 @@ def _export_initial( if cls: return cls(pipeline_response, None, {}) - _export_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export'} # type: ignore + _export_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export"} # type: ignore @distributed_trace - def begin_export( + def begin_export( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ExportClusterParameters", + parameters: _models.ExportClusterParameters, **kwargs: Any ) -> LROPoller[None]: """Exports a database file from target database. @@ -1319,22 +1494,29 @@ def begin_export( :rtype: ~azure.core.polling.LROPoller[None] :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] + _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-01-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[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._export_initial( + raw_result = self._export_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1344,8 +1526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1354,26 +1542,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_export.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export'} # type: ignore + begin_export.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export"} # type: ignore - def _force_unlink_initial( + def _force_unlink_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ForceUnlinkParameters", + parameters: _models.ForceUnlinkParameters, **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 {}) - 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-01-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[None] _json = self._serialize.body(parameters, 'ForceUnlinkParameters') @@ -1382,14 +1573,21 @@ def _force_unlink_initial( cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._force_unlink_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]: @@ -1399,16 +1597,16 @@ def _force_unlink_initial( if cls: return cls(pipeline_response, None, {}) - _force_unlink_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink'} # type: ignore + _force_unlink_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink"} # type: ignore @distributed_trace - def begin_force_unlink( + def begin_force_unlink( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.ForceUnlinkParameters", + parameters: _models.ForceUnlinkParameters, **kwargs: Any ) -> LROPoller[None]: """Forcibly removes the link to the specified database resource. @@ -1433,22 +1631,29 @@ def begin_force_unlink( :rtype: ~azure.core.polling.LROPoller[None] :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] + _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-01-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[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._force_unlink_initial( + raw_result = self._force_unlink_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1458,8 +1663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1468,7 +1679,6 @@ 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_force_unlink.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink'} # type: ignore + begin_force_unlink.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/forceUnlink"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations.py index 47ab7b65c833..44a407658c9b 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_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 -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,8 +16,8 @@ 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 @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Cache/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Cache/operations") # 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 ) -class Operations(object): - """Operations 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 Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`operations` 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 list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available REST API operations of the Microsoft.Cache provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -84,27 +85,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + 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( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, 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 @@ -118,7 +130,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]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Cache/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Cache/operations"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations_status_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations_status_operations.py index 730479fc553c..8b24d0056e0a 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations_status_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # 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, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import 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 @@ -31,55 +32,55 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "location": _SERIALIZER.url("location", location, 'str'), "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), "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') # 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 OperationsStatusOperations(object): - """OperationsStatusOperations 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 OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`operations_status` 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 get( @@ -87,7 +88,7 @@ def get( location: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Gets the status of operation. :param location: The region the operation is in. @@ -99,23 +100,35 @@ def get( :rtype: ~azure.mgmt.redisenterprise.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -130,5 +143,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_patch.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/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/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_endpoint_connections_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_endpoint_connections_operations.py index 261806fa52d6..727673d641a1 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_endpoint_connections_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_endpoint_connections_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,31 +35,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # 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 ) @@ -71,10 +73,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -82,21 +88,19 @@ def build_get_request( "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') # 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 ) @@ -107,16 +111,19 @@ def build_put_request_initial( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -124,23 +131,21 @@ def build_put_request_initial( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_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 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 @@ -154,10 +159,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), @@ -165,45 +174,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_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="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations 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 PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`private_endpoint_connections` 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 list( @@ -211,7 +216,7 @@ def list( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """Lists all the private endpoint connections associated with the RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -225,11 +230,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + 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: @@ -237,10 +247,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -248,10 +261,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -265,7 +281,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]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -303,11 +323,16 @@ def get( :rtype: ~azure.mgmt.redisenterprise.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -315,12 +340,19 @@ def get( cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -335,7 +367,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _put_initial( @@ -343,16 +375,20 @@ def _put_initial( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: 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-01-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -361,14 +397,21 @@ def _put_initial( cluster_name=cluster_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._put_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 [201]: @@ -382,7 +425,7 @@ def _put_initial( return deserialized - _put_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _put_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -391,9 +434,9 @@ def begin_put( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Updates the state of the specified private endpoint connection associated with the RedisEnterprise cluster. @@ -420,36 +463,48 @@ def begin_put( ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.PrivateEndpointConnection] :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.PrivateEndpointConnection"] + _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-01-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.PrivateEndpointConnection] + 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._put_initial( + raw_result = self._put_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, properties=properties, + 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('PrivateEndpointConnection', 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( @@ -458,13 +513,12 @@ 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_put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -485,11 +539,16 @@ def delete( :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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -497,12 +556,19 @@ def delete( cluster_name=cluster_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -513,5 +579,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_link_resources_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_link_resources_operations.py index 3f7b16a133a4..2eb6fbbced0c 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_link_resources_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_private_link_resources_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 -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,8 +16,8 @@ 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 @@ -32,55 +33,55 @@ def build_list_by_cluster_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # 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 PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations 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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`private_link_resources` 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 list_by_cluster( @@ -88,7 +89,7 @@ def list_by_cluster( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + ) -> Iterable[_models.PrivateLinkResourceListResult]: """Gets the private link resources that need to be created for a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -102,11 +103,16 @@ def list_by_cluster( ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + 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: @@ -114,10 +120,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_cluster.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: @@ -125,10 +134,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -142,7 +154,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]: @@ -156,4 +172,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources'} # type: ignore + list_by_cluster.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateLinkResources"} # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_redis_enterprise_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_redis_enterprise_operations.py index 0521e520257d..bea6fd329825 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_redis_enterprise_operations.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_redis_enterprise_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,39 +34,40 @@ def build_create_request_initial( cluster_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Cluster] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _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 @@ -78,39 +79,40 @@ def build_update_request_initial( cluster_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ClusterUpdate] = None, content: Any = 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-01-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 = "2022-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _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 @@ -123,31 +125,33 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # 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="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -158,31 +162,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), "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') # 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 ) @@ -192,30 +198,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _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 ) @@ -224,68 +232,72 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01" - 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-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise") 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') # 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 RedisEnterpriseOperations(object): - """RedisEnterpriseOperations 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 RedisEnterpriseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redisenterprise.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.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`redis_enterprise` 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_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: 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-01-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.Cluster] _json = self._serialize.body(parameters, 'Cluster') @@ -293,14 +305,21 @@ def _create_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_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]: @@ -318,7 +337,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace @@ -326,9 +345,9 @@ def begin_create( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: _models.Cluster, **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Creates or updates an existing (overwrite/recreate, with potential downtime) cache cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -349,35 +368,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.Cluster] :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.Cluster"] + _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-01-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.Cluster] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, + 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('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -386,25 +417,28 @@ 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: _models.ClusterUpdate, **kwargs: Any - ) -> Optional["_models.Cluster"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Cluster"]] + ) -> Optional[_models.Cluster]: 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-01-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.Cluster]] _json = self._serialize.body(parameters, 'ClusterUpdate') @@ -412,14 +446,21 @@ def _update_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, 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]: @@ -435,7 +476,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace @@ -443,9 +484,9 @@ def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: _models.ClusterUpdate, **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Updates an existing RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -466,35 +507,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.Cluster] :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.Cluster"] + _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-01-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.Cluster] + 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, cluster_name=cluster_name, parameters=parameters, + 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('Cluster', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -503,34 +556,45 @@ 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.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, **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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -540,11 +604,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -568,18 +632,25 @@ 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-01-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, cluster_name=cluster_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -589,8 +660,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -599,10 +676,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.Cache/redisEnterprise/{clusterName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace def get( @@ -610,7 +686,7 @@ def get( resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Gets information about a RedisEnterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -622,23 +698,35 @@ def get( :rtype: ~azure.mgmt.redisenterprise.models.Cluster :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] 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-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # 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]: @@ -653,7 +741,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}"} # type: ignore @distributed_trace @@ -661,7 +749,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ClusterList"]: + ) -> Iterable[_models.ClusterList]: """Lists all RedisEnterprise clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -671,31 +759,42 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.ClusterList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterList] + 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( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, 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 @@ -709,7 +808,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]: @@ -723,13 +826,13 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.ClusterList"]: + ) -> Iterable[_models.ClusterList]: """Gets all RedisEnterprise clusters in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -737,29 +840,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.ClusterList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterList] + 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, 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, 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 +887,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]: @@ -787,4 +905,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise"} # type: ignore