From a8076dd907d5bda35f26a4c7eaae1d98ad78eeed Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 8 Oct 2024 13:40:55 +0000 Subject: [PATCH] CodeGen from PR 30711 in Azure/azure-rest-api-specs Merge e89015b5129f2ea3fc8a90d61939ecce260433e1 into c4f4021bea5eee306fa202df3c7e19271a9f1f96 --- .../azure-mgmt-redisenterprise/_meta.json | 8 +- .../mgmt/redisenterprise/_configuration.py | 4 +- .../azure/mgmt/redisenterprise/_patch.py | 1 + .../_redis_enterprise_management_client.py | 14 +- .../mgmt/redisenterprise/_serialization.py | 4 +- .../azure/mgmt/redisenterprise/_vendor.py | 16 - .../azure/mgmt/redisenterprise/_version.py | 2 +- .../redisenterprise/aio/_configuration.py | 4 +- .../azure/mgmt/redisenterprise/aio/_patch.py | 1 + .../_redis_enterprise_management_client.py | 14 +- .../aio/operations/__init__.py | 2 + .../_access_policy_assignment_operations.py | 589 ++++++++++++++ .../aio/operations/_databases_operations.py | 328 +++++--- .../aio/operations/_operations.py | 15 +- .../_operations_status_operations.py | 16 +- ...private_endpoint_connections_operations.py | 84 +- .../_private_link_resources_operations.py | 17 +- .../_redis_enterprise_operations.py | 137 ++-- .../mgmt/redisenterprise/models/__init__.py | 20 + .../redisenterprise/models/_models_py3.py | 443 ++++++++-- ...edis_enterprise_management_client_enums.py | 107 ++- .../redisenterprise/operations/__init__.py | 2 + .../_access_policy_assignment_operations.py | 754 ++++++++++++++++++ .../operations/_databases_operations.py | 407 ++++++---- .../redisenterprise/operations/_operations.py | 17 +- .../_operations_status_operations.py | 18 +- ...private_endpoint_connections_operations.py | 108 ++- .../_private_link_resources_operations.py | 23 +- .../_redis_enterprise_operations.py | 165 ++-- .../generated_samples/operations_list.py | 2 +- .../operations_status_get.py | 4 +- ..._access_policy_assignment_create_update.py | 47 ++ ...erprise_access_policy_assignment_delete.py | 43 + ...enterprise_access_policy_assignment_get.py | 44 + ...terprise_access_policy_assignments_list.py | 44 + .../redis_enterprise_create.py | 6 +- .../redis_enterprise_databases_create.py | 7 +- ...e_databases_create_with_geo_replication.py | 11 +- .../redis_enterprise_databases_delete.py | 4 +- .../redis_enterprise_databases_export.py | 6 +- .../redis_enterprise_databases_flush.py | 8 +- .../redis_enterprise_databases_force_link.py | 4 +- ...redis_enterprise_databases_force_unlink.py | 8 +- .../redis_enterprise_databases_get.py | 4 +- .../redis_enterprise_databases_import.py | 6 +- ...is_enterprise_databases_list_by_cluster.py | 4 +- .../redis_enterprise_databases_list_keys.py | 4 +- ...dis_enterprise_databases_regenerate_key.py | 6 +- .../redis_enterprise_databases_update.py | 7 +- ...rise_databases_upgrade_db_redis_version.py | 4 +- .../redis_enterprise_delete.py | 4 +- ...rise_delete_private_endpoint_connection.py | 4 +- .../generated_samples/redis_enterprise_get.py | 4 +- ...erprise_get_private_endpoint_connection.py | 4 +- .../redis_enterprise_list.py | 4 +- ...redis_enterprise_list_by_resource_group.py | 4 +- ...prise_list_private_endpoint_connections.py | 4 +- ..._enterprise_list_private_link_resources.py | 4 +- ...erprise_put_private_endpoint_connection.py | 6 +- .../redis_enterprise_update.py | 6 +- .../generated_tests/conftest.py | 43 + ...ent_access_policy_assignment_operations.py | 82 ++ ...cess_policy_assignment_operations_async.py | 87 ++ ...erprise_management_databases_operations.py | 232 ++++++ ...e_management_databases_operations_async.py | 263 ++++++ ..._redis_enterprise_management_operations.py | 29 + ..._enterprise_management_operations_async.py | 30 + ...management_operations_status_operations.py | 31 + ...ment_operations_status_operations_async.py | 32 + ...private_endpoint_connections_operations.py | 78 ++ ...e_endpoint_connections_operations_async.py | 87 ++ ...ement_private_link_resources_operations.py | 31 + ...private_link_resources_operations_async.py | 32 + ..._management_redis_enterprise_operations.py | 167 ++++ ...ement_redis_enterprise_operations_async.py | 180 +++++ .../azure-mgmt-redisenterprise/setup.py | 1 + 76 files changed, 4390 insertions(+), 652 deletions(-) delete mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_vendor.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_access_policy_assignment_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_access_policy_assignment_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_create_update.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_delete.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_get.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignments_list.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/conftest.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations_async.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations.py create mode 100644 sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations_async.py diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json b/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json index c91812882773..b8335cc15394 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/_meta.json @@ -1,11 +1,11 @@ { - "commit": "3940cd77b8d74b58d4a8b3a80388ff890052be67", + "commit": "cc22db4b6a6b212856e5bb217db68ff1f81a5767", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.7", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/redisenterprise/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/redisenterprise/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/redisenterprise/resource-manager/readme.md" } \ No newline at end of file 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 d0f4abb5d457..0d7dc327ee5f 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_configuration.py @@ -28,13 +28,13 @@ class RedisEnterpriseManagementClientConfiguration: # pylint: disable=too-many- :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-03-01-preview") + api_version: str = kwargs.pop("api_version", "2024-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_patch.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_patch.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): 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 584727367ffc..c88c90e15cbe 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 @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -18,6 +19,7 @@ from ._configuration import RedisEnterpriseManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + AccessPolicyAssignmentOperations, DatabasesOperations, Operations, OperationsStatusOperations, @@ -31,7 +33,7 @@ from azure.core.credentials import TokenCredential -class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-version-keyword +class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for managing Redis Enterprise resources in Azure. :ivar operations: Operations operations @@ -42,6 +44,9 @@ class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-ver :vartype redis_enterprise: azure.mgmt.redisenterprise.operations.RedisEnterpriseOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.redisenterprise.operations.DatabasesOperations + :ivar access_policy_assignment: AccessPolicyAssignmentOperations operations + :vartype access_policy_assignment: + azure.mgmt.redisenterprise.operations.AccessPolicyAssignmentOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.redisenterprise.operations.PrivateEndpointConnectionsOperations @@ -54,7 +59,7 @@ class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-ver :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-03-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -103,6 +108,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_policy_assignment = AccessPolicyAssignmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -135,7 +143,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "RedisEnterpriseManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_serialization.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_serialization.py index 2f781d740827..8139854b97bb 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_serialization.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_vendor.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_version.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_version.py index 48b05f9c489c..48944bf3938a 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_version.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.1.0b1" +VERSION = "2.0.0" 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 0f536b3195b2..2f7ead7a27c9 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 @@ -28,13 +28,13 @@ class RedisEnterpriseManagementClientConfiguration: # pylint: disable=too-many- :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-03-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-03-01-preview") + api_version: str = kwargs.pop("api_version", "2024-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_patch.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_patch.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): 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 c0ea1a58947e..c287b5e691b8 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 @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -18,6 +19,7 @@ from .._serialization import Deserializer, Serializer from ._configuration import RedisEnterpriseManagementClientConfiguration from .operations import ( + AccessPolicyAssignmentOperations, DatabasesOperations, Operations, OperationsStatusOperations, @@ -31,7 +33,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-version-keyword +class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for managing Redis Enterprise resources in Azure. :ivar operations: Operations operations @@ -43,6 +45,9 @@ class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-ver :vartype redis_enterprise: azure.mgmt.redisenterprise.aio.operations.RedisEnterpriseOperations :ivar databases: DatabasesOperations operations :vartype databases: azure.mgmt.redisenterprise.aio.operations.DatabasesOperations + :ivar access_policy_assignment: AccessPolicyAssignmentOperations operations + :vartype access_policy_assignment: + azure.mgmt.redisenterprise.aio.operations.AccessPolicyAssignmentOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.redisenterprise.aio.operations.PrivateEndpointConnectionsOperations @@ -55,7 +60,7 @@ class RedisEnterpriseManagementClient: # pylint: disable=client-accepts-api-ver :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-03-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -104,6 +109,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_policy_assignment = AccessPolicyAssignmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -138,7 +146,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "RedisEnterpriseManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self 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 8aa6b8ab91d6..663e4bdcb58e 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 @@ -10,6 +10,7 @@ from ._operations_status_operations import OperationsStatusOperations from ._redis_enterprise_operations import RedisEnterpriseOperations from ._databases_operations import DatabasesOperations +from ._access_policy_assignment_operations import AccessPolicyAssignmentOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations @@ -22,6 +23,7 @@ "OperationsStatusOperations", "RedisEnterpriseOperations", "DatabasesOperations", + "AccessPolicyAssignmentOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", ] diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_access_policy_assignment_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_access_policy_assignment_operations.py new file mode 100644 index 000000000000..772fee8fcd16 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/aio/operations/_access_policy_assignment_operations.py @@ -0,0 +1,589 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, 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 + +from ... import models as _models +from ...operations._access_policy_assignment_operations import ( + build_create_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AccessPolicyAssignmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redisenterprise.aio.RedisEnterpriseManagementClient`'s + :attr:`access_policy_assignment` attribute. + """ + + models = _models + + 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_update_initial( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.AccessPolicyAssignment, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccessPolicyAssignment") + + _request = build_create_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: _models.AccessPolicyAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. + Required. + :type parameters: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either AccessPolicyAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either AccessPolicyAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.AccessPolicyAssignment, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. Is + either a AccessPolicyAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AccessPolicyAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessPolicyAssignment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessPolicyAssignment", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AccessPolicyAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AccessPolicyAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> _models.AccessPolicyAssignment: + """Gets information about access policy assignment for database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :return: AccessPolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccessPolicyAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessPolicyAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a single access policy assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AccessPolicyAssignment"]: + """Gets all access policy assignments.. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :return: An iterator like instance of either AccessPolicyAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccessPolicyAssignmentList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessPolicyAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) 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 3c41302440e8..d6c3d971e191 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._databases_operations import ( build_create_request, build_delete_request, @@ -40,7 +41,6 @@ build_force_unlink_request, build_get_request, build_import_method_request, - build_import_request, build_list_by_cluster_request, build_list_keys_request, build_regenerate_key_request, @@ -48,6 +48,10 @@ build_upgrade_db_redis_version_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,7 +79,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_cluster( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.Database"]: - """Gets all databases in the specified RedisEnterprise cluster. + """Gets all databases in the specified Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -92,7 +96,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +115,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +130,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -164,8 +166,8 @@ async def _create_initial( database_name: str, parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,7 +180,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -200,10 +202,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -211,15 +213,15 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -336,10 +338,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -371,8 +374,8 @@ async def _update_initial( database_name: str, parameters: Union[_models.DatabaseUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Database]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,7 +388,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -407,10 +410,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -418,16 +421,25 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -541,10 +553,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -573,7 +586,7 @@ def get_long_running_output(pipeline_response): async def get( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any ) -> _models.Database: - """Gets information about a database in a RedisEnterprise cluster. + """Gets information about a database in a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -586,7 +599,7 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -609,7 +622,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -624,17 +636,17 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,7 +658,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -657,10 +669,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -668,12 +680,27 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -701,7 +728,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -711,6 +738,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -739,7 +767,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- async def list_keys( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any ) -> _models.AccessKeys: - """Retrieves the access keys for the RedisEnterprise database. + """Retrieves the access keys for the Redis Enterprise database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -752,7 +780,7 @@ async def list_keys( :rtype: ~azure.mgmt.redisenterprise.models.AccessKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -775,7 +803,6 @@ async def list_keys( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -790,7 +817,7 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessKeys", pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -804,8 +831,8 @@ async def _regenerate_key_initial( database_name: str, parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AccessKeys]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -818,7 +845,7 @@ async def _regenerate_key_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AccessKeys]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -840,10 +867,10 @@ async def _regenerate_key_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -851,16 +878,25 @@ async def _regenerate_key_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AccessKeys", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -875,7 +911,7 @@ async def begin_regenerate_key( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -906,7 +942,7 @@ async def begin_regenerate_key( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -935,7 +971,7 @@ async def begin_regenerate_key( parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -974,10 +1010,11 @@ async def begin_regenerate_key( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessKeys", pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1002,15 +1039,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _import_initial( # pylint: disable=inconsistent-return-statements + async def _import_method_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ImportClusterParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1023,7 +1060,7 @@ async def _import_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1033,7 +1070,7 @@ async def _import_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "ImportClusterParameters") - _request = build_import_request( + _request = build_import_method_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1045,10 +1082,10 @@ async def _import_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1056,12 +1093,27 @@ async def _import_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_import_method( @@ -1158,7 +1210,7 @@ async def begin_import_method( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._import_initial( # type: ignore + raw_result = await self._import_method_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1170,6 +1222,7 @@ async def begin_import_method( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1194,15 +1247,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _export_initial( # pylint: disable=inconsistent-return-statements + async def _export_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ExportClusterParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1215,7 +1268,7 @@ async def _export_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1237,10 +1290,10 @@ async def _export_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1248,12 +1301,27 @@ async def _export_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_export( @@ -1350,7 +1418,7 @@ async def begin_export( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._export_initial( # type: ignore + raw_result = await self._export_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1362,6 +1430,7 @@ async def begin_export( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1386,15 +1455,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _force_unlink_initial( # pylint: disable=inconsistent-return-statements + async def _force_unlink_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ForceUnlinkParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1407,7 +1476,7 @@ async def _force_unlink_initial( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1429,10 +1498,10 @@ async def _force_unlink_initial( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1440,12 +1509,27 @@ async def _force_unlink_initial( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_force_unlink( @@ -1542,7 +1626,7 @@ async def begin_force_unlink( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._force_unlink_initial( # type: ignore + raw_result = await self._force_unlink_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1554,6 +1638,7 @@ async def begin_force_unlink( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1578,15 +1663,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-return-statements + async def _force_link_to_replication_group_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ForceLinkParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1599,7 +1684,7 @@ async def _force_link_to_replication_group_initial( # pylint: disable=inconsist api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1621,10 +1706,10 @@ async def _force_link_to_replication_group_initial( # pylint: disable=inconsist headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1632,6 +1717,10 @@ async def _force_link_to_replication_group_initial( # pylint: disable=inconsist response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1642,8 +1731,12 @@ async def _force_link_to_replication_group_initial( # pylint: disable=inconsist "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_force_link_to_replication_group( @@ -1746,7 +1839,7 @@ async def begin_force_link_to_replication_group( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._force_link_to_replication_group_initial( # type: ignore + raw_result = await self._force_link_to_replication_group_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1758,6 +1851,7 @@ async def begin_force_link_to_replication_group( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1782,15 +1876,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _flush_initial( # pylint: disable=inconsistent-return-statements + async def _flush_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.FlushParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1803,7 +1897,7 @@ async def _flush_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1825,10 +1919,10 @@ async def _flush_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1836,6 +1930,10 @@ async def _flush_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1847,8 +1945,12 @@ async def _flush_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_flush( @@ -1945,7 +2047,7 @@ async def begin_flush( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._flush_initial( # type: ignore + raw_result = await self._flush_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1957,6 +2059,7 @@ async def begin_flush( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1980,10 +2083,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-statements + async def _upgrade_db_redis_version_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1995,7 +2098,7 @@ async def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-ret _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_upgrade_db_redis_version_request( resource_group_name=resource_group_name, @@ -2006,10 +2109,10 @@ async def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2017,6 +2120,10 @@ async def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2027,8 +2134,12 @@ async def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-ret "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_upgrade_db_redis_version( @@ -2056,7 +2167,7 @@ async def begin_upgrade_db_redis_version( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._upgrade_db_redis_version_initial( # type: ignore + raw_result = await self._upgrade_db_redis_version_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -2066,6 +2177,7 @@ async def begin_upgrade_db_redis_version( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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 5fc950fca576..daf642321434 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,7 +85,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -98,7 +100,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 cfea62131ab9..e3632908b7c3 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 -from ..._vendor import _convert_request from ...operations._operations_status_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -62,7 +65,7 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. :rtype: ~azure.mgmt.redisenterprise.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,7 +87,6 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -99,7 +101,7 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore 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 d166c6ed0d4d..132bae146416 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_delete_request, build_get_request, @@ -38,6 +39,10 @@ build_put_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +70,7 @@ def __init__(self, *args, **kwargs) -> None: def list( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """Lists all the private endpoint connections associated with the RedisEnterprise cluster. + """Lists all the private endpoint connections associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -84,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -119,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -153,7 +156,7 @@ async def get_next(next_link=None): async def get( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the RedisEnterprise cluster. + """Gets the specified private endpoint connection associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -167,7 +170,7 @@ async def get( :rtype: ~azure.mgmt.redisenterprise.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,7 +193,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -205,7 +207,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -219,8 +221,8 @@ async def _put_initial( private_endpoint_connection_name: str, properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,7 +235,7 @@ async def _put_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -255,10 +257,10 @@ async def _put_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -266,11 +268,15 @@ async def _put_initial( response = pipeline_response.http_response if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -288,8 +294,8 @@ async def begin_put( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -322,8 +328,8 @@ async def begin_put( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -354,8 +360,8 @@ async def begin_put( properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -396,10 +402,11 @@ async def begin_put( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -421,10 +428,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +443,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -447,10 +454,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -458,6 +465,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -469,14 +480,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes the specified private endpoint connection associated with the RedisEnterprise cluster. + """Deletes the specified private endpoint connection associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -499,7 +514,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -509,6 +524,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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 57ed7c2cdd61..6ff0baeb8b34 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_cluster_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_cluster( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateLinkResource"]: - """Gets the private link resources that need to be created for a RedisEnterprise cluster. + """Gets the private link resources that need to be created for a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -74,7 +77,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,7 +96,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -109,7 +111,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 c615ccdaaba2..2f30cc7ad0e5 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._redis_enterprise_operations import ( build_create_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,8 +70,8 @@ def __init__(self, *args, **kwargs) -> None: async def _create_initial( self, resource_group_name: str, cluster_name: str, parameters: Union[_models.Cluster, IO[bytes]], **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,7 +84,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -100,10 +105,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -111,15 +116,15 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -143,7 +148,7 @@ async def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Required. :type parameters: ~azure.mgmt.redisenterprise.models.Cluster :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -171,7 +176,7 @@ async def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -193,7 +198,7 @@ async def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Is either a + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Is either a Cluster type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.redisenterprise.models.Cluster or IO[bytes] :return: An instance of AsyncLROPoller that returns either Cluster or the result of @@ -222,10 +227,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -256,8 +262,8 @@ async def _update_initial( cluster_name: str, parameters: Union[_models.ClusterUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Cluster]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +276,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Cluster]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -291,10 +297,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -302,16 +308,25 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -325,14 +340,14 @@ async def begin_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Required. :type parameters: ~azure.mgmt.redisenterprise.models.ClusterUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -353,14 +368,14 @@ async def begin_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -379,14 +394,14 @@ async def begin_update( parameters: Union[_models.ClusterUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Is either a + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Is either a ClusterUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.redisenterprise.models.ClusterUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either Cluster or the result of @@ -415,10 +430,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -443,10 +459,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +472,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -468,10 +482,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -479,16 +493,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a RedisEnterprise cache cluster. + """Deletes a Redis Enterprise cache cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -508,7 +537,7 @@ async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -517,6 +546,7 @@ async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwar params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -543,7 +573,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- @distributed_trace_async async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: - """Gets information about a RedisEnterprise cluster. + """Gets information about a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -554,7 +584,7 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) :rtype: ~azure.mgmt.redisenterprise.models.Cluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,7 +606,6 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -591,7 +620,7 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -600,7 +629,7 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: - """Lists all RedisEnterprise clusters in a resource group. + """Lists all Redis Enterprise clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -615,7 +644,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -633,7 +662,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -649,7 +677,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -681,7 +708,7 @@ async def get_next(next_link=None): @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: - """Gets all RedisEnterprise clusters in the specified subscription. + """Lists all Redis Enterprise clusters in the specified subscription. :return: An iterator like instance of either Cluster or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redisenterprise.models.Cluster] @@ -693,7 +720,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -710,7 +737,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -726,7 +752,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 38fc58acf8b2..e9a168c77e6a 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 @@ -7,6 +7,9 @@ # -------------------------------------------------------------------------- from ._models_py3 import AccessKeys +from ._models_py3 import AccessPolicyAssignment +from ._models_py3 import AccessPolicyAssignmentList +from ._models_py3 import AccessPolicyAssignmentPropertiesUser from ._models_py3 import Cluster from ._models_py3 import ClusterList from ._models_py3 import ClusterPropertiesEncryption @@ -40,19 +43,25 @@ from ._models_py3 import PrivateLinkResourceListResult from ._models_py3 import PrivateLinkServiceConnectionState from ._models_py3 import ProxyResource +from ._models_py3 import ProxyResourceAutoGenerated from ._models_py3 import RegenerateKeyParameters from ._models_py3 import Resource +from ._models_py3 import ResourceAutoGenerated from ._models_py3 import Sku +from ._models_py3 import SystemData from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentity from ._redis_enterprise_management_client_enums import AccessKeyType +from ._redis_enterprise_management_client_enums import AccessKeysAuthentication from ._redis_enterprise_management_client_enums import ActionType from ._redis_enterprise_management_client_enums import AofFrequency from ._redis_enterprise_management_client_enums import ClusteringPolicy from ._redis_enterprise_management_client_enums import CmkIdentityType +from ._redis_enterprise_management_client_enums import CreatedByType from ._redis_enterprise_management_client_enums import DeferUpgradeSetting from ._redis_enterprise_management_client_enums import EvictionPolicy +from ._redis_enterprise_management_client_enums import HighAvailability from ._redis_enterprise_management_client_enums import LinkState from ._redis_enterprise_management_client_enums import ManagedServiceIdentityType from ._redis_enterprise_management_client_enums import Origin @@ -61,6 +70,7 @@ from ._redis_enterprise_management_client_enums import Protocol from ._redis_enterprise_management_client_enums import ProvisioningState from ._redis_enterprise_management_client_enums import RdbFrequency +from ._redis_enterprise_management_client_enums import RedundancyMode from ._redis_enterprise_management_client_enums import ResourceState from ._redis_enterprise_management_client_enums import SkuName from ._redis_enterprise_management_client_enums import TlsVersion @@ -70,6 +80,9 @@ __all__ = [ "AccessKeys", + "AccessPolicyAssignment", + "AccessPolicyAssignmentList", + "AccessPolicyAssignmentPropertiesUser", "Cluster", "ClusterList", "ClusterPropertiesEncryption", @@ -103,18 +116,24 @@ "PrivateLinkResourceListResult", "PrivateLinkServiceConnectionState", "ProxyResource", + "ProxyResourceAutoGenerated", "RegenerateKeyParameters", "Resource", + "ResourceAutoGenerated", "Sku", + "SystemData", "TrackedResource", "UserAssignedIdentity", "AccessKeyType", + "AccessKeysAuthentication", "ActionType", "AofFrequency", "ClusteringPolicy", "CmkIdentityType", + "CreatedByType", "DeferUpgradeSetting", "EvictionPolicy", + "HighAvailability", "LinkState", "ManagedServiceIdentityType", "Origin", @@ -123,6 +142,7 @@ "Protocol", "ProvisioningState", "RdbFrequency", + "RedundancyMode", "ResourceState", "SkuName", "TlsVersion", 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 9b7ff18a570e..25ec1a9de38a 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -79,6 +80,133 @@ def __init__(self, **kwargs: Any) -> None: self.type = None +class ProxyResourceAutoGenerated(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + +class AccessPolicyAssignment(ProxyResourceAutoGenerated): + """Describes the access policy assignment of Redis Enterprise database. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar provisioning_state: Current provisioning status of the access policy assignment. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState + :ivar access_policy_name: Name of access policy under specific access policy assignment. Only + "default" policy is supported for now. + :vartype access_policy_name: str + :ivar user: The user associated with the access policy. + :vartype user: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignmentPropertiesUser + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "access_policy_name": {"pattern": r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "access_policy_name": {"key": "properties.accessPolicyName", "type": "str"}, + "user": {"key": "properties.user", "type": "AccessPolicyAssignmentPropertiesUser"}, + } + + def __init__( + self, + *, + access_policy_name: Optional[str] = None, + user: Optional["_models.AccessPolicyAssignmentPropertiesUser"] = None, + **kwargs: Any + ) -> None: + """ + :keyword access_policy_name: Name of access policy under specific access policy assignment. + Only "default" policy is supported for now. + :paramtype access_policy_name: str + :keyword user: The user associated with the access policy. + :paramtype user: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignmentPropertiesUser + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.access_policy_name = access_policy_name + self.user = user + + +class AccessPolicyAssignmentList(_serialization.Model): + """The response of a list-all operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of access policy assignments. + :vartype value: list[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :ivar next_link: The URI to fetch the next page of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AccessPolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.AccessPolicyAssignment"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of access policy assignments. + :paramtype value: list[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class AccessPolicyAssignmentPropertiesUser(_serialization.Model): + """The user associated with the access policy. + + :ivar object_id: The object ID of the user. + :vartype object_id: str + """ + + _attribute_map = { + "object_id": {"key": "objectId", "type": "str"}, + } + + def __init__(self, *, object_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword object_id: The object ID of the user. + :paramtype object_id: str + """ + super().__init__(**kwargs) + self.object_id = object_id + + class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. @@ -129,7 +257,7 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes - """Describes the RedisEnterprise cluster. + """Describes the Redis Enterprise cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -153,8 +281,14 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype zones: list[str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.redisenterprise.models.ManagedServiceIdentity + :ivar high_availability: Enabled by default. If highAvailability is disabled, the data set is + not replicated. This affects the availability SLA, and increases the risk of data loss. Known + values are: "Enabled" and "Disabled". + :vartype high_availability: str or ~azure.mgmt.redisenterprise.models.HighAvailability :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", and "1.2". + Newer versions can be added in the future. Note that TLS 1.0 and TLS 1.1 are now completely + obsolete -- you cannot use them. They are mentioned only for the sake of consistency with old + API versions. Known values are: "1.0", "1.1", and "1.2". :vartype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :ivar encryption: Encryption-at-rest configuration for the cluster. :vartype encryption: ~azure.mgmt.redisenterprise.models.ClusterPropertiesEncryption @@ -163,6 +297,9 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar provisioning_state: Current provisioning status of the cluster. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState + :ivar redundancy_mode: Explains the current redundancy strategy of the cluster, which affects + the expected SLA. Known values are: "None", "LR", and "ZR". + :vartype redundancy_mode: str or ~azure.mgmt.redisenterprise.models.RedundancyMode :ivar resource_state: Current resource status of the cluster. Known values are: "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled", "Scaling", and "ScalingFailed". @@ -170,7 +307,7 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar redis_version: Version of redis the cluster supports, e.g. '6'. :vartype redis_version: str :ivar private_endpoint_connections: List of private endpoint connections associated with the - specified RedisEnterprise cluster. + specified Redis Enterprise cluster. :vartype private_endpoint_connections: list[~azure.mgmt.redisenterprise.models.PrivateEndpointConnection] """ @@ -183,6 +320,7 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes "sku": {"required": True}, "host_name": {"readonly": True}, "provisioning_state": {"readonly": True}, + "redundancy_mode": {"readonly": True}, "resource_state": {"readonly": True}, "redis_version": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, @@ -197,10 +335,12 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes "sku": {"key": "sku", "type": "Sku"}, "zones": {"key": "zones", "type": "[str]"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "high_availability": {"key": "properties.highAvailability", "type": "str"}, "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, "encryption": {"key": "properties.encryption", "type": "ClusterPropertiesEncryption"}, "host_name": {"key": "properties.hostName", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "redundancy_mode": {"key": "properties.redundancyMode", "type": "str"}, "resource_state": {"key": "properties.resourceState", "type": "str"}, "redis_version": {"key": "properties.redisVersion", "type": "str"}, "private_endpoint_connections": { @@ -217,6 +357,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, + high_availability: Optional[Union[str, "_models.HighAvailability"]] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, encryption: Optional["_models.ClusterPropertiesEncryption"] = None, **kwargs: Any @@ -232,8 +373,14 @@ def __init__( :paramtype zones: list[str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.redisenterprise.models.ManagedServiceIdentity + :keyword high_availability: Enabled by default. If highAvailability is disabled, the data set + is not replicated. This affects the availability SLA, and increases the risk of data loss. + Known values are: "Enabled" and "Disabled". + :paramtype high_availability: str or ~azure.mgmt.redisenterprise.models.HighAvailability :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", and "1.2". + Newer versions can be added in the future. Note that TLS 1.0 and TLS 1.1 are now completely + obsolete -- you cannot use them. They are mentioned only for the sake of consistency with old + API versions. Known values are: "1.0", "1.1", and "1.2". :paramtype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :keyword encryption: Encryption-at-rest configuration for the cluster. :paramtype encryption: ~azure.mgmt.redisenterprise.models.ClusterPropertiesEncryption @@ -242,10 +389,12 @@ def __init__( self.sku = sku self.zones = zones self.identity = identity + self.high_availability = high_availability self.minimum_tls_version = minimum_tls_version self.encryption = encryption self.host_name = None self.provisioning_state = None + self.redundancy_mode = None self.resource_state = None self.redis_version = None self.private_endpoint_connections = None @@ -402,8 +551,8 @@ def __init__( self.identity_type = identity_type -class ClusterUpdate(_serialization.Model): - """A partial update to the RedisEnterprise cluster. +class ClusterUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes + """A partial update to the Redis Enterprise cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -413,8 +562,14 @@ class ClusterUpdate(_serialization.Model): :vartype identity: ~azure.mgmt.redisenterprise.models.ManagedServiceIdentity :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar high_availability: Enabled by default. If highAvailability is disabled, the data set is + not replicated. This affects the availability SLA, and increases the risk of data loss. Known + values are: "Enabled" and "Disabled". + :vartype high_availability: str or ~azure.mgmt.redisenterprise.models.HighAvailability :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", and "1.2". + Newer versions can be added in the future. Note that TLS 1.0 and TLS 1.1 are now completely + obsolete -- you cannot use them. They are mentioned only for the sake of consistency with old + API versions. Known values are: "1.0", "1.1", and "1.2". :vartype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :ivar encryption: Encryption-at-rest configuration for the cluster. :vartype encryption: ~azure.mgmt.redisenterprise.models.ClusterPropertiesEncryption @@ -423,6 +578,9 @@ class ClusterUpdate(_serialization.Model): :ivar provisioning_state: Current provisioning status of the cluster. Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.redisenterprise.models.ProvisioningState + :ivar redundancy_mode: Explains the current redundancy strategy of the cluster, which affects + the expected SLA. Known values are: "None", "LR", and "ZR". + :vartype redundancy_mode: str or ~azure.mgmt.redisenterprise.models.RedundancyMode :ivar resource_state: Current resource status of the cluster. Known values are: "Running", "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled", "Scaling", and "ScalingFailed". @@ -430,7 +588,7 @@ class ClusterUpdate(_serialization.Model): :ivar redis_version: Version of redis the cluster supports, e.g. '6'. :vartype redis_version: str :ivar private_endpoint_connections: List of private endpoint connections associated with the - specified RedisEnterprise cluster. + specified Redis Enterprise cluster. :vartype private_endpoint_connections: list[~azure.mgmt.redisenterprise.models.PrivateEndpointConnection] """ @@ -438,6 +596,7 @@ class ClusterUpdate(_serialization.Model): _validation = { "host_name": {"readonly": True}, "provisioning_state": {"readonly": True}, + "redundancy_mode": {"readonly": True}, "resource_state": {"readonly": True}, "redis_version": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, @@ -447,10 +606,12 @@ class ClusterUpdate(_serialization.Model): "sku": {"key": "sku", "type": "Sku"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "tags": {"key": "tags", "type": "{str}"}, + "high_availability": {"key": "properties.highAvailability", "type": "str"}, "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, "encryption": {"key": "properties.encryption", "type": "ClusterPropertiesEncryption"}, "host_name": {"key": "properties.hostName", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "redundancy_mode": {"key": "properties.redundancyMode", "type": "str"}, "resource_state": {"key": "properties.resourceState", "type": "str"}, "redis_version": {"key": "properties.redisVersion", "type": "str"}, "private_endpoint_connections": { @@ -465,6 +626,7 @@ def __init__( sku: Optional["_models.Sku"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, tags: Optional[Dict[str, str]] = None, + high_availability: Optional[Union[str, "_models.HighAvailability"]] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, encryption: Optional["_models.ClusterPropertiesEncryption"] = None, **kwargs: Any @@ -476,8 +638,14 @@ def __init__( :paramtype identity: ~azure.mgmt.redisenterprise.models.ManagedServiceIdentity :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword high_availability: Enabled by default. If highAvailability is disabled, the data set + is not replicated. This affects the availability SLA, and increases the risk of data loss. + Known values are: "Enabled" and "Disabled". + :paramtype high_availability: str or ~azure.mgmt.redisenterprise.models.HighAvailability :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", and "1.2". + Newer versions can be added in the future. Note that TLS 1.0 and TLS 1.1 are now completely + obsolete -- you cannot use them. They are mentioned only for the sake of consistency with old + API versions. Known values are: "1.0", "1.1", and "1.2". :paramtype minimum_tls_version: str or ~azure.mgmt.redisenterprise.models.TlsVersion :keyword encryption: Encryption-at-rest configuration for the cluster. :paramtype encryption: ~azure.mgmt.redisenterprise.models.ClusterPropertiesEncryption @@ -486,16 +654,59 @@ def __init__( self.sku = sku self.identity = identity self.tags = tags + self.high_availability = high_availability self.minimum_tls_version = minimum_tls_version self.encryption = encryption self.host_name = None self.provisioning_state = None + self.redundancy_mode = None self.resource_state = None self.redis_version = None self.private_endpoint_connections = None -class ProxyResource(Resource): +class ResourceAutoGenerated(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redisenterprise.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(ResourceAutoGenerated): """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. @@ -509,11 +720,14 @@ class ProxyResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redisenterprise.models.SystemData """ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes - """Describes a database on the RedisEnterprise cluster. + """Describes a database on the Redis Enterprise cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -525,6 +739,9 @@ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redisenterprise.models.SystemData :ivar client_protocol: Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is TLS-encrypted. Known values are: "Encrypted" and "Plaintext". @@ -539,8 +756,9 @@ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled", "Scaling", and "ScalingFailed". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState - :ivar clustering_policy: Clustering policy - default is OSSCluster. Specified at create time. - Known values are: "EnterpriseCluster" and "OSSCluster". + :ivar clustering_policy: Clustering policy - default is OSSCluster. This property must be + chosen at create time, and cannot be changed without deleting the database. Known values are: + "EnterpriseCluster" and "OSSCluster". :vartype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", @@ -557,15 +775,21 @@ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes :ivar redis_version: Version of Redis the database is running on, e.g. '6.0'. :vartype redis_version: str :ivar defer_upgrade: Option to defer upgrade when newest version is released - default is - NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and + NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and "NotDeferred". :vartype defer_upgrade: str or ~azure.mgmt.redisenterprise.models.DeferUpgradeSetting + :ivar access_keys_authentication: This property can be Enabled/Disabled to allow or deny access + with the current access keys. Can be updated even after database is created. Known values are: + "Disabled" and "Enabled". + :vartype access_keys_authentication: str or + ~azure.mgmt.redisenterprise.models.AccessKeysAuthentication """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "provisioning_state": {"readonly": True}, "resource_state": {"readonly": True}, "redis_version": {"readonly": True}, @@ -575,6 +799,7 @@ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "client_protocol": {"key": "properties.clientProtocol", "type": "str"}, "port": {"key": "properties.port", "type": "int"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, @@ -586,6 +811,7 @@ class Database(ProxyResource): # pylint: disable=too-many-instance-attributes "geo_replication": {"key": "properties.geoReplication", "type": "DatabasePropertiesGeoReplication"}, "redis_version": {"key": "properties.redisVersion", "type": "str"}, "defer_upgrade": {"key": "properties.deferUpgrade", "type": "str"}, + "access_keys_authentication": {"key": "properties.accessKeysAuthentication", "type": "str"}, } def __init__( @@ -599,6 +825,7 @@ def __init__( modules: Optional[List["_models.Module"]] = None, geo_replication: Optional["_models.DatabasePropertiesGeoReplication"] = None, defer_upgrade: Optional[Union[str, "_models.DeferUpgradeSetting"]] = None, + access_keys_authentication: Optional[Union[str, "_models.AccessKeysAuthentication"]] = None, **kwargs: Any ) -> None: """ @@ -609,8 +836,9 @@ def __init__( :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. Known values are: "EnterpriseCluster" and "OSSCluster". + :keyword clustering_policy: Clustering policy - default is OSSCluster. This property must be + chosen at create time, and cannot be changed without deleting the database. Known values are: + "EnterpriseCluster" and "OSSCluster". :paramtype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", @@ -625,9 +853,14 @@ def __init__( database. :paramtype geo_replication: ~azure.mgmt.redisenterprise.models.DatabasePropertiesGeoReplication :keyword defer_upgrade: Option to defer upgrade when newest version is released - default is - NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and + NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and "NotDeferred". :paramtype defer_upgrade: str or ~azure.mgmt.redisenterprise.models.DeferUpgradeSetting + :keyword access_keys_authentication: This property can be Enabled/Disabled to allow or deny + access with the current access keys. Can be updated even after database is created. Known + values are: "Disabled" and "Enabled". + :paramtype access_keys_authentication: str or + ~azure.mgmt.redisenterprise.models.AccessKeysAuthentication """ super().__init__(**kwargs) self.client_protocol = client_protocol @@ -641,6 +874,7 @@ def __init__( self.geo_replication = geo_replication self.redis_version = None self.defer_upgrade = defer_upgrade + self.access_keys_authentication = access_keys_authentication class DatabaseList(_serialization.Model): @@ -706,7 +940,7 @@ def __init__( class DatabaseUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes - """A partial update to the RedisEnterprise database. + """A partial update to the Redis Enterprise database. Variables are only populated by the server, and will be ignored when sending a request. @@ -724,8 +958,9 @@ class DatabaseUpdate(_serialization.Model): # pylint: disable=too-many-instance "Creating", "CreateFailed", "Updating", "UpdateFailed", "Deleting", "DeleteFailed", "Enabling", "EnableFailed", "Disabling", "DisableFailed", "Disabled", "Scaling", and "ScalingFailed". :vartype resource_state: str or ~azure.mgmt.redisenterprise.models.ResourceState - :ivar clustering_policy: Clustering policy - default is OSSCluster. Specified at create time. - Known values are: "EnterpriseCluster" and "OSSCluster". + :ivar clustering_policy: Clustering policy - default is OSSCluster. This property must be + chosen at create time, and cannot be changed without deleting the database. Known values are: + "EnterpriseCluster" and "OSSCluster". :vartype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy :ivar eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", @@ -742,9 +977,14 @@ class DatabaseUpdate(_serialization.Model): # pylint: disable=too-many-instance :ivar redis_version: Version of Redis the database is running on, e.g. '6.0'. :vartype redis_version: str :ivar defer_upgrade: Option to defer upgrade when newest version is released - default is - NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and + NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and "NotDeferred". :vartype defer_upgrade: str or ~azure.mgmt.redisenterprise.models.DeferUpgradeSetting + :ivar access_keys_authentication: This property can be Enabled/Disabled to allow or deny access + with the current access keys. Can be updated even after database is created. Known values are: + "Disabled" and "Enabled". + :vartype access_keys_authentication: str or + ~azure.mgmt.redisenterprise.models.AccessKeysAuthentication """ _validation = { @@ -765,6 +1005,7 @@ class DatabaseUpdate(_serialization.Model): # pylint: disable=too-many-instance "geo_replication": {"key": "properties.geoReplication", "type": "DatabasePropertiesGeoReplication"}, "redis_version": {"key": "properties.redisVersion", "type": "str"}, "defer_upgrade": {"key": "properties.deferUpgrade", "type": "str"}, + "access_keys_authentication": {"key": "properties.accessKeysAuthentication", "type": "str"}, } def __init__( @@ -778,6 +1019,7 @@ def __init__( modules: Optional[List["_models.Module"]] = None, geo_replication: Optional["_models.DatabasePropertiesGeoReplication"] = None, defer_upgrade: Optional[Union[str, "_models.DeferUpgradeSetting"]] = None, + access_keys_authentication: Optional[Union[str, "_models.AccessKeysAuthentication"]] = None, **kwargs: Any ) -> None: """ @@ -788,8 +1030,9 @@ def __init__( :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. Known values are: "EnterpriseCluster" and "OSSCluster". + :keyword clustering_policy: Clustering policy - default is OSSCluster. This property must be + chosen at create time, and cannot be changed without deleting the database. Known values are: + "EnterpriseCluster" and "OSSCluster". :paramtype clustering_policy: str or ~azure.mgmt.redisenterprise.models.ClusteringPolicy :keyword eviction_policy: Redis eviction policy - default is VolatileLRU. Known values are: "AllKeysLFU", "AllKeysLRU", "AllKeysRandom", "VolatileLRU", "VolatileLFU", "VolatileTTL", @@ -804,9 +1047,14 @@ def __init__( database. :paramtype geo_replication: ~azure.mgmt.redisenterprise.models.DatabasePropertiesGeoReplication :keyword defer_upgrade: Option to defer upgrade when newest version is released - default is - NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and + NotDeferred. Learn more: https://aka.ms/redisversionupgrade. Known values are: "Deferred" and "NotDeferred". :paramtype defer_upgrade: str or ~azure.mgmt.redisenterprise.models.DeferUpgradeSetting + :keyword access_keys_authentication: This property can be Enabled/Disabled to allow or deny + access with the current access keys. Can be updated even after database is created. Known + values are: "Disabled" and "Enabled". + :paramtype access_keys_authentication: str or + ~azure.mgmt.redisenterprise.models.AccessKeysAuthentication """ super().__init__(**kwargs) self.client_protocol = client_protocol @@ -820,6 +1068,7 @@ def __init__( self.geo_replication = geo_replication self.redis_version = None self.defer_upgrade = defer_upgrade + self.access_keys_authentication = access_keys_authentication class ErrorAdditionalInfo(_serialization.Model): @@ -1003,7 +1252,7 @@ def __init__(self, *, group_nickname: str, linked_databases: List["_models.Linke class ForceUnlinkParameters(_serialization.Model): - """Parameters for a Redis Enterprise Active Geo Replication Force Unlink operation. + """Parameters for a redis enterprise active geo-replication force unlink operation. All required parameters must be populated in order to send to server. @@ -1372,14 +1621,17 @@ def __init__( class Persistence(_serialization.Model): - """Persistence-related configuration for the RedisEnterprise database. + """Persistence-related configuration for the Redis Enterprise database. - :ivar aof_enabled: Sets whether AOF is enabled. + :ivar aof_enabled: Sets whether AOF is enabled. Note that at most one of AOF or RDB persistence + may be enabled. :vartype aof_enabled: bool - :ivar rdb_enabled: Sets whether RDB is enabled. + :ivar rdb_enabled: Sets whether RDB is enabled. Note that at most one of AOF or RDB persistence + may be enabled. :vartype rdb_enabled: bool - :ivar aof_frequency: Sets the frequency at which data is written to disk. Known values are: - "1s" and "always". + :ivar aof_frequency: Sets the frequency at which data is written to disk. Defaults to '1s', + meaning 'every second'. Note that the 'always' setting is deprecated, because of its + performance impact. Known values are: "1s" and "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. Known values are: "1h", "6h", and "12h". @@ -1403,12 +1655,15 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword aof_enabled: Sets whether AOF is enabled. + :keyword aof_enabled: Sets whether AOF is enabled. Note that at most one of AOF or RDB + persistence may be enabled. :paramtype aof_enabled: bool - :keyword rdb_enabled: Sets whether RDB is enabled. + :keyword rdb_enabled: Sets whether RDB is enabled. Note that at most one of AOF or RDB + persistence may be enabled. :paramtype rdb_enabled: bool - :keyword aof_frequency: Sets the frequency at which data is written to disk. Known values are: - "1s" and "always". + :keyword aof_frequency: Sets the frequency at which data is written to disk. Defaults to '1s', + meaning 'every second'. Note that the 'always' setting is deprecated, because of its + performance impact. Known values are: "1s" and "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. Known values are: "1h", "6h", and "12h". @@ -1673,17 +1928,32 @@ def __init__(self, *, key_type: Union[str, "_models.AccessKeyType"], **kwargs: A class Sku(_serialization.Model): - """SKU parameters supplied to the create RedisEnterprise operation. + """SKU parameters supplied to the create Redis Enterprise cluster operation. All required parameters must be populated in order to send to server. - :ivar name: The type of RedisEnterprise cluster to deploy. Possible values: (Enterprise_E10, - EnterpriseFlash_F300 etc.). Required. Known values are: "Enterprise_E5", "Enterprise_E10", - "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "EnterpriseFlash_F300", - "EnterpriseFlash_F700", and "EnterpriseFlash_F1500". + :ivar name: The level of Redis Enterprise cluster to deploy. Possible values: ('Balanced_B5', + 'MemoryOptimized_M10', 'ComputeOptimized_X5', etc.). For more information on SKUs see the + latest pricing documentation. Note that additional SKUs may become supported in the future. + Required. Known values are: "Enterprise_E1", "Enterprise_E5", "Enterprise_E10", + "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "Enterprise_E200", "Enterprise_E400", + "EnterpriseFlash_F300", "EnterpriseFlash_F700", "EnterpriseFlash_F1500", "Balanced_B0", + "Balanced_B1", "Balanced_B3", "Balanced_B5", "Balanced_B10", "Balanced_B20", "Balanced_B50", + "Balanced_B100", "Balanced_B150", "Balanced_B250", "Balanced_B350", "Balanced_B500", + "Balanced_B700", "Balanced_B1000", "MemoryOptimized_M10", "MemoryOptimized_M20", + "MemoryOptimized_M50", "MemoryOptimized_M100", "MemoryOptimized_M150", "MemoryOptimized_M250", + "MemoryOptimized_M350", "MemoryOptimized_M500", "MemoryOptimized_M700", + "MemoryOptimized_M1000", "MemoryOptimized_M1500", "MemoryOptimized_M2000", + "ComputeOptimized_X3", "ComputeOptimized_X5", "ComputeOptimized_X10", "ComputeOptimized_X20", + "ComputeOptimized_X50", "ComputeOptimized_X100", "ComputeOptimized_X150", + "ComputeOptimized_X250", "ComputeOptimized_X350", "ComputeOptimized_X500", + "ComputeOptimized_X700", "FlashOptimized_A250", "FlashOptimized_A500", "FlashOptimized_A700", + "FlashOptimized_A1000", "FlashOptimized_A1500", "FlashOptimized_A2000", and + "FlashOptimized_A4500". :vartype name: str or ~azure.mgmt.redisenterprise.models.SkuName - :ivar capacity: The size of the RedisEnterprise cluster. Defaults to 2 or 3 depending on SKU. - Valid values are (2, 4, 6, ...) for Enterprise SKUs and (3, 9, 15, ...) for Flash SKUs. + :ivar capacity: This property is only used with Enterprise and EnterpriseFlash SKUs. Determines + the size of the cluster. Valid values are (2, 4, 6, ...) for Enterprise SKUs and (3, 9, 15, + ...) for EnterpriseFlash SKUs. :vartype capacity: int """ @@ -1698,13 +1968,28 @@ class Sku(_serialization.Model): def __init__(self, *, name: Union[str, "_models.SkuName"], capacity: Optional[int] = None, **kwargs: Any) -> None: """ - :keyword name: The type of RedisEnterprise cluster to deploy. Possible values: (Enterprise_E10, - EnterpriseFlash_F300 etc.). Required. Known values are: "Enterprise_E5", "Enterprise_E10", - "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "EnterpriseFlash_F300", - "EnterpriseFlash_F700", and "EnterpriseFlash_F1500". + :keyword name: The level of Redis Enterprise cluster to deploy. Possible values: + ('Balanced_B5', 'MemoryOptimized_M10', 'ComputeOptimized_X5', etc.). For more information on + SKUs see the latest pricing documentation. Note that additional SKUs may become supported in + the future. Required. Known values are: "Enterprise_E1", "Enterprise_E5", "Enterprise_E10", + "Enterprise_E20", "Enterprise_E50", "Enterprise_E100", "Enterprise_E200", "Enterprise_E400", + "EnterpriseFlash_F300", "EnterpriseFlash_F700", "EnterpriseFlash_F1500", "Balanced_B0", + "Balanced_B1", "Balanced_B3", "Balanced_B5", "Balanced_B10", "Balanced_B20", "Balanced_B50", + "Balanced_B100", "Balanced_B150", "Balanced_B250", "Balanced_B350", "Balanced_B500", + "Balanced_B700", "Balanced_B1000", "MemoryOptimized_M10", "MemoryOptimized_M20", + "MemoryOptimized_M50", "MemoryOptimized_M100", "MemoryOptimized_M150", "MemoryOptimized_M250", + "MemoryOptimized_M350", "MemoryOptimized_M500", "MemoryOptimized_M700", + "MemoryOptimized_M1000", "MemoryOptimized_M1500", "MemoryOptimized_M2000", + "ComputeOptimized_X3", "ComputeOptimized_X5", "ComputeOptimized_X10", "ComputeOptimized_X20", + "ComputeOptimized_X50", "ComputeOptimized_X100", "ComputeOptimized_X150", + "ComputeOptimized_X250", "ComputeOptimized_X350", "ComputeOptimized_X500", + "ComputeOptimized_X700", "FlashOptimized_A250", "FlashOptimized_A500", "FlashOptimized_A700", + "FlashOptimized_A1000", "FlashOptimized_A1500", "FlashOptimized_A2000", and + "FlashOptimized_A4500". :paramtype name: str or ~azure.mgmt.redisenterprise.models.SkuName - :keyword capacity: The size of the RedisEnterprise cluster. Defaults to 2 or 3 depending on - SKU. Valid values are (2, 4, 6, ...) for Enterprise SKUs and (3, 9, 15, ...) for Flash SKUs. + :keyword capacity: This property is only used with Enterprise and EnterpriseFlash SKUs. + Determines the size of the cluster. Valid values are (2, 4, 6, ...) for Enterprise SKUs and (3, + 9, 15, ...) for EnterpriseFlash SKUs. :paramtype capacity: int """ super().__init__(**kwargs) @@ -1712,6 +1997,70 @@ def __init__(self, *, name: Union[str, "_models.SkuName"], capacity: Optional[in self.capacity = capacity +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.redisenterprise.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.redisenterprise.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.redisenterprise.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.redisenterprise.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. 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 a377eaba64be..c78d2d2c5b56 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 @@ -10,6 +10,15 @@ from azure.core import CaseInsensitiveEnumMeta +class AccessKeysAuthentication(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property can be Enabled/Disabled to allow or deny access with the current access keys. Can + be updated even after database is created. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + class AccessKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Which access key to regenerate.""" @@ -24,17 +33,25 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AofFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Sets the frequency at which data is written to disk.""" + """Sets the frequency at which data is written to disk. Defaults to '1s', meaning 'every second'. + Note that the 'always' setting is deprecated, because of its performance impact. + """ ONE_S = "1s" ALWAYS = "always" class ClusteringPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Clustering policy - default is OSSCluster. Specified at create time.""" + """Clustering policy - default is OSSCluster. This property must be chosen at create time, and + cannot be changed without deleting the database. + """ ENTERPRISE_CLUSTER = "EnterpriseCluster" + """Enterprise clustering policy uses only the classic redis protocol, which does not support redis + cluster commands.""" OSS_CLUSTER = "OSSCluster" + """OSS clustering policy follows the redis cluster specification, and requires all clients to + support redis clustering.""" class CmkIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -46,6 +63,15 @@ class CmkIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_ASSIGNED_IDENTITY = "userAssignedIdentity" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class DeferUpgradeSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Option to defer upgrade when newest version is released - default is NotDeferred. Learn more: https://aka.ms/redisversionupgrade. @@ -68,6 +94,15 @@ class EvictionPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): NO_EVICTION = "NoEviction" +class HighAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enabled by default. If highAvailability is disabled, the data set is not replicated. This + affects the availability SLA, and increases the risk of data loss. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class LinkState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the link between the database resources.""" @@ -144,6 +179,17 @@ class RdbFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): TWELVE_H = "12h" +class RedundancyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Explains the current redundancy strategy of the cluster, which affects the expected SLA.""" + + NONE = "None" + """No redundancy. Availability loss will occur.""" + LR = "LR" + """Local redundancy with high availability.""" + ZR = "ZR" + """Zone redundant. Higher availability.""" + + class ResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Current resource status.""" @@ -164,22 +210,73 @@ class ResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of RedisEnterprise cluster to deploy. Possible values: (Enterprise_E10, - EnterpriseFlash_F300 etc.). + """The level of Redis Enterprise cluster to deploy. Possible values: ('Balanced_B5', + 'MemoryOptimized_M10', 'ComputeOptimized_X5', etc.). For more information on SKUs see the + latest pricing documentation. Note that additional SKUs may become supported in the future. """ + ENTERPRISE_E1 = "Enterprise_E1" ENTERPRISE_E5 = "Enterprise_E5" ENTERPRISE_E10 = "Enterprise_E10" ENTERPRISE_E20 = "Enterprise_E20" ENTERPRISE_E50 = "Enterprise_E50" ENTERPRISE_E100 = "Enterprise_E100" + ENTERPRISE_E200 = "Enterprise_E200" + ENTERPRISE_E400 = "Enterprise_E400" ENTERPRISE_FLASH_F300 = "EnterpriseFlash_F300" ENTERPRISE_FLASH_F700 = "EnterpriseFlash_F700" ENTERPRISE_FLASH_F1500 = "EnterpriseFlash_F1500" + BALANCED_B0 = "Balanced_B0" + BALANCED_B1 = "Balanced_B1" + BALANCED_B3 = "Balanced_B3" + BALANCED_B5 = "Balanced_B5" + BALANCED_B10 = "Balanced_B10" + BALANCED_B20 = "Balanced_B20" + BALANCED_B50 = "Balanced_B50" + BALANCED_B100 = "Balanced_B100" + BALANCED_B150 = "Balanced_B150" + BALANCED_B250 = "Balanced_B250" + BALANCED_B350 = "Balanced_B350" + BALANCED_B500 = "Balanced_B500" + BALANCED_B700 = "Balanced_B700" + BALANCED_B1000 = "Balanced_B1000" + MEMORY_OPTIMIZED_M10 = "MemoryOptimized_M10" + MEMORY_OPTIMIZED_M20 = "MemoryOptimized_M20" + MEMORY_OPTIMIZED_M50 = "MemoryOptimized_M50" + MEMORY_OPTIMIZED_M100 = "MemoryOptimized_M100" + MEMORY_OPTIMIZED_M150 = "MemoryOptimized_M150" + MEMORY_OPTIMIZED_M250 = "MemoryOptimized_M250" + MEMORY_OPTIMIZED_M350 = "MemoryOptimized_M350" + MEMORY_OPTIMIZED_M500 = "MemoryOptimized_M500" + MEMORY_OPTIMIZED_M700 = "MemoryOptimized_M700" + MEMORY_OPTIMIZED_M1000 = "MemoryOptimized_M1000" + MEMORY_OPTIMIZED_M1500 = "MemoryOptimized_M1500" + MEMORY_OPTIMIZED_M2000 = "MemoryOptimized_M2000" + COMPUTE_OPTIMIZED_X3 = "ComputeOptimized_X3" + COMPUTE_OPTIMIZED_X5 = "ComputeOptimized_X5" + COMPUTE_OPTIMIZED_X10 = "ComputeOptimized_X10" + COMPUTE_OPTIMIZED_X20 = "ComputeOptimized_X20" + COMPUTE_OPTIMIZED_X50 = "ComputeOptimized_X50" + COMPUTE_OPTIMIZED_X100 = "ComputeOptimized_X100" + COMPUTE_OPTIMIZED_X150 = "ComputeOptimized_X150" + COMPUTE_OPTIMIZED_X250 = "ComputeOptimized_X250" + COMPUTE_OPTIMIZED_X350 = "ComputeOptimized_X350" + COMPUTE_OPTIMIZED_X500 = "ComputeOptimized_X500" + COMPUTE_OPTIMIZED_X700 = "ComputeOptimized_X700" + FLASH_OPTIMIZED_A250 = "FlashOptimized_A250" + FLASH_OPTIMIZED_A500 = "FlashOptimized_A500" + FLASH_OPTIMIZED_A700 = "FlashOptimized_A700" + FLASH_OPTIMIZED_A1000 = "FlashOptimized_A1000" + FLASH_OPTIMIZED_A1500 = "FlashOptimized_A1500" + FLASH_OPTIMIZED_A2000 = "FlashOptimized_A2000" + FLASH_OPTIMIZED_A4500 = "FlashOptimized_A4500" class TlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The minimum TLS version for the cluster to support, e.g. '1.2'.""" + """The minimum TLS version for the cluster to support, e.g. '1.2'. Newer versions can be added in + the future. Note that TLS 1.0 and TLS 1.1 are now completely obsolete -- you cannot use them. + They are mentioned only for the sake of consistency with old API versions. + """ ONE0 = "1.0" ONE1 = "1.1" 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 8aa6b8ab91d6..663e4bdcb58e 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 @@ -10,6 +10,7 @@ from ._operations_status_operations import OperationsStatusOperations from ._redis_enterprise_operations import RedisEnterpriseOperations from ._databases_operations import DatabasesOperations +from ._access_policy_assignment_operations import AccessPolicyAssignmentOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations @@ -22,6 +23,7 @@ "OperationsStatusOperations", "RedisEnterpriseOperations", "DatabasesOperations", + "AccessPolicyAssignmentOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", ] diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_access_policy_assignment_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_access_policy_assignment_operations.py new file mode 100644 index 000000000000..b84d11dfcef6 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/azure/mgmt/redisenterprise/operations/_access_policy_assignment_operations.py @@ -0,0 +1,754 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +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 .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_update_request( + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # 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", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", access_policy_assignment_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # 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", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", access_policy_assignment_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # 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", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", access_policy_assignment_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/accessPolicyAssignments", + ) # 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", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AccessPolicyAssignmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redisenterprise.RedisEnterpriseManagementClient`'s + :attr:`access_policy_assignment` attribute. + """ + + models = _models + + 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_update_initial( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.AccessPolicyAssignment, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccessPolicyAssignment") + + _request = build_create_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: _models.AccessPolicyAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. + Required. + :type parameters: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either AccessPolicyAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either AccessPolicyAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.AccessPolicyAssignment, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AccessPolicyAssignment]: + """Creates/Updates a particular access policy assignment for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the create access policy assignment for database. Is + either a AccessPolicyAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment or IO[bytes] + :return: An instance of LROPoller that returns either AccessPolicyAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessPolicyAssignment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AccessPolicyAssignment", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AccessPolicyAssignment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AccessPolicyAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> _models.AccessPolicyAssignment: + """Gets information about access policy assignment for database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :return: AccessPolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.redisenterprise.models.AccessPolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccessPolicyAssignment] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessPolicyAssignment", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + access_policy_assignment_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a single access policy assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :param access_policy_assignment_name: The name of the Redis Enterprise database access policy + assignment. Required. + :type access_policy_assignment_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + access_policy_assignment_name=access_policy_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.AccessPolicyAssignment"]: + """Gets all access policy assignments.. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Redis Enterprise cluster. Required. + :type cluster_name: str + :param database_name: The name of the Redis Enterprise database. Required. + :type database_name: str + :return: An iterator like instance of either AccessPolicyAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.AccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AccessPolicyAssignmentList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessPolicyAssignmentList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) 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 a4538714c8ce..5d12e947e7ba 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_cluster_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +63,9 @@ def build_list_by_cluster_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -78,7 +85,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -91,7 +98,9 @@ def build_create_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -115,7 +124,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +137,9 @@ def build_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -152,7 +163,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +175,9 @@ def build_get_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -186,7 +199,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,7 +211,9 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -220,7 +235,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -232,7 +247,9 @@ def build_list_keys_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -254,7 +271,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -267,7 +284,9 @@ def build_regenerate_key_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -285,13 +304,13 @@ def build_regenerate_key_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_import_request( +def build_import_method_request( resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -304,7 +323,9 @@ def build_import_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -328,7 +349,7 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -341,7 +362,9 @@ def build_export_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -365,7 +388,7 @@ def build_force_unlink_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -378,7 +401,9 @@ def build_force_unlink_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -402,7 +427,7 @@ def build_force_link_to_replication_group_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -415,7 +440,9 @@ def build_force_link_to_replication_group_request( # pylint: disable=name-too-l "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -439,7 +466,7 @@ def build_flush_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -452,7 +479,9 @@ def build_flush_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -476,7 +505,7 @@ def build_upgrade_db_redis_version_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -488,7 +517,9 @@ def build_upgrade_db_redis_version_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "databaseName": _SERIALIZER.url("database_name", database_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -527,7 +558,7 @@ def __init__(self, *args, **kwargs): def list_by_cluster( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> Iterable["_models.Database"]: - """Gets all databases in the specified RedisEnterprise cluster. + """Gets all databases in the specified Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -544,7 +575,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -563,7 +594,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -579,7 +609,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -616,8 +645,8 @@ def _create_initial( database_name: str, parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,7 +659,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -652,10 +681,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -663,15 +692,15 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -785,10 +814,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -819,8 +849,8 @@ def _update_initial( database_name: str, parameters: Union[_models.DatabaseUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Database]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -833,7 +863,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -855,10 +885,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -866,16 +896,25 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -986,10 +1025,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1015,7 +1055,7 @@ def get_long_running_output(pipeline_response): @distributed_trace def get(self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any) -> _models.Database: - """Gets information about a database in a RedisEnterprise cluster. + """Gets information about a database in a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1028,7 +1068,7 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * :rtype: ~azure.mgmt.redisenterprise.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1051,7 +1091,6 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1066,17 +1105,17 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1088,7 +1127,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1099,10 +1138,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1110,12 +1149,27 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1143,7 +1197,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1153,6 +1207,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1180,7 +1235,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- def list_keys( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any ) -> _models.AccessKeys: - """Retrieves the access keys for the RedisEnterprise database. + """Retrieves the access keys for the Redis Enterprise database. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1193,7 +1248,7 @@ def list_keys( :rtype: ~azure.mgmt.redisenterprise.models.AccessKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1216,7 +1271,6 @@ def list_keys( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1231,7 +1285,7 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessKeys", pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1245,8 +1299,8 @@ def _regenerate_key_initial( database_name: str, parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AccessKeys]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1259,7 +1313,7 @@ def _regenerate_key_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AccessKeys]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1281,10 +1335,10 @@ def _regenerate_key_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1292,16 +1346,25 @@ def _regenerate_key_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AccessKeys", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1316,7 +1379,7 @@ def begin_regenerate_key( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1346,7 +1409,7 @@ def begin_regenerate_key( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1374,7 +1437,7 @@ def begin_regenerate_key( parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AccessKeys]: - """Regenerates the RedisEnterprise database's access keys. + """Regenerates the Redis Enterprise database's access keys. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -1412,10 +1475,11 @@ def begin_regenerate_key( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessKeys", pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1439,15 +1503,15 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _import_initial( # pylint: disable=inconsistent-return-statements + def _import_method_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ImportClusterParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,7 +1524,7 @@ def _import_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1470,7 +1534,7 @@ def _import_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "ImportClusterParameters") - _request = build_import_request( + _request = build_import_method_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1482,10 +1546,10 @@ def _import_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1493,12 +1557,27 @@ def _import_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_import_method( @@ -1595,7 +1674,7 @@ def begin_import_method( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._import_initial( # type: ignore + raw_result = self._import_method_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1607,6 +1686,7 @@ def begin_import_method( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1630,15 +1710,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _export_initial( # pylint: disable=inconsistent-return-statements + def _export_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ExportClusterParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1651,7 +1731,7 @@ def _export_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1673,10 +1753,10 @@ def _export_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1684,12 +1764,27 @@ def _export_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_export( @@ -1786,7 +1881,7 @@ def begin_export( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._export_initial( # type: ignore + raw_result = self._export_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1798,6 +1893,7 @@ def begin_export( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1821,15 +1917,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _force_unlink_initial( # pylint: disable=inconsistent-return-statements + def _force_unlink_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ForceUnlinkParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1842,7 +1938,7 @@ def _force_unlink_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1864,10 +1960,10 @@ def _force_unlink_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1875,12 +1971,27 @@ def _force_unlink_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_force_unlink( @@ -1977,7 +2088,7 @@ def begin_force_unlink( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._force_unlink_initial( # type: ignore + raw_result = self._force_unlink_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1989,6 +2100,7 @@ def begin_force_unlink( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -2012,15 +2124,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-return-statements + def _force_link_to_replication_group_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.ForceLinkParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2033,7 +2145,7 @@ def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-re api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2055,10 +2167,10 @@ def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-re headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2066,6 +2178,10 @@ def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-re response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2076,8 +2192,12 @@ def _force_link_to_replication_group_initial( # pylint: disable=inconsistent-re "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_force_link_to_replication_group( @@ -2180,7 +2300,7 @@ def begin_force_link_to_replication_group( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._force_link_to_replication_group_initial( # type: ignore + raw_result = self._force_link_to_replication_group_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -2192,6 +2312,7 @@ def begin_force_link_to_replication_group( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -2215,15 +2336,15 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _flush_initial( # pylint: disable=inconsistent-return-statements + def _flush_initial( self, resource_group_name: str, cluster_name: str, database_name: str, parameters: Union[_models.FlushParameters, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2236,7 +2357,7 @@ def _flush_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2258,10 +2379,10 @@ def _flush_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2269,6 +2390,10 @@ def _flush_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2280,8 +2405,12 @@ def _flush_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_flush( @@ -2378,7 +2507,7 @@ def begin_flush( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._flush_initial( # type: ignore + raw_result = self._flush_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -2390,6 +2519,7 @@ def begin_flush( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -2413,10 +2543,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-statements + def _upgrade_db_redis_version_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2428,7 +2558,7 @@ def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-st _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_upgrade_db_redis_version_request( resource_group_name=resource_group_name, @@ -2439,10 +2569,10 @@ def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2450,6 +2580,10 @@ def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2460,8 +2594,12 @@ def _upgrade_db_redis_version_initial( # pylint: disable=inconsistent-return-st "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_upgrade_db_redis_version( @@ -2489,7 +2627,7 @@ def begin_upgrade_db_redis_version( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._upgrade_db_redis_version_initial( # type: ignore + raw_result = self._upgrade_db_redis_version_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -2499,6 +2637,7 @@ def begin_upgrade_db_redis_version( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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 a03034372ce8..b4c6a14e1065 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 ef595d1951d7..bcca8f2a0b05 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +97,7 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat :rtype: ~azure.mgmt.redisenterprise.models.OperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,7 +119,6 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,7 +133,7 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationStatus", pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore 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 d70e8118f334..fd074218a448 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +60,9 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -80,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +99,9 @@ def build_get_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), @@ -120,7 +129,7 @@ def build_put_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -133,7 +142,9 @@ def build_put_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" @@ -163,7 +174,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -175,7 +186,9 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" @@ -216,7 +229,7 @@ def __init__(self, *args, **kwargs): def list( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateEndpointConnection"]: - """Lists all the private endpoint connections associated with the RedisEnterprise cluster. + """Lists all the private endpoint connections associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -235,7 +248,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,7 +267,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -270,7 +282,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -304,7 +315,7 @@ def get_next(next_link=None): def get( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: - """Gets the specified private endpoint connection associated with the RedisEnterprise cluster. + """Gets the specified private endpoint connection associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -318,7 +329,7 @@ def get( :rtype: ~azure.mgmt.redisenterprise.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +352,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -356,7 +366,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -370,8 +380,8 @@ def _put_initial( private_endpoint_connection_name: str, properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,7 +394,7 @@ def _put_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -406,10 +416,10 @@ def _put_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -417,11 +427,15 @@ def _put_initial( response = pipeline_response.http_response if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -439,8 +453,8 @@ def begin_put( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -473,8 +487,8 @@ def begin_put( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -505,8 +519,8 @@ def begin_put( properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: - """Updates the state of the specified private endpoint connection associated with the - RedisEnterprise cluster. + """Updates the state of the specified private endpoint connection associated with the Redis + Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -547,10 +561,11 @@ def begin_put( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -572,10 +587,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -587,7 +602,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -598,10 +613,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -609,6 +624,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -620,14 +639,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: - """Deletes the specified private endpoint connection associated with the RedisEnterprise cluster. + """Deletes the specified private endpoint connection associated with the Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -650,7 +673,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -660,6 +683,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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 749032dd8605..9fedc98c55f2 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 @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_by_cluster_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +57,9 @@ def build_list_by_cluster_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -92,7 +97,7 @@ def __init__(self, *args, **kwargs): def list_by_cluster( self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateLinkResource"]: - """Gets the private link resources that need to be created for a RedisEnterprise cluster. + """Gets the private link resources that need to be created for a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -109,7 +114,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,7 +133,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -144,7 +148,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request 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 892fd1660435..9aa13bbd3cdf 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 @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -58,7 +63,9 @@ def build_create_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -81,7 +88,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -94,7 +101,9 @@ def build_update_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -117,7 +126,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +138,9 @@ def build_delete_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -148,7 +159,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +171,9 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^[A-Za-z0-9]{1,60}$"), + "clusterName": _SERIALIZER.url( + "cluster_name", cluster_name, "str", pattern=r"^(?=.{1,60}$)[A-Za-z0-9]+(-[A-Za-z0-9]+)*$" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } @@ -179,7 +192,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,7 +222,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -250,8 +263,8 @@ def __init__(self, *args, **kwargs): def _create_initial( self, resource_group_name: str, cluster_name: str, parameters: Union[_models.Cluster, IO[bytes]], **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,7 +277,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -285,10 +298,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -296,15 +309,15 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -328,7 +341,7 @@ def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Required. :type parameters: ~azure.mgmt.redisenterprise.models.Cluster :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -355,7 +368,7 @@ def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -376,7 +389,7 @@ def begin_create( :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Create RedisEnterprise operation. Is either a + :param parameters: Parameters supplied to the Create Redis Enterprise operation. Is either a Cluster type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.redisenterprise.models.Cluster or IO[bytes] :return: An instance of LROPoller that returns either Cluster or the result of cls(response) @@ -404,10 +417,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -437,8 +451,8 @@ def _update_initial( cluster_name: str, parameters: Union[_models.ClusterUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Cluster]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -451,7 +465,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Cluster]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -472,10 +486,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -483,16 +497,25 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -506,14 +529,14 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Required. :type parameters: ~azure.mgmt.redisenterprise.models.ClusterUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -533,14 +556,14 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Required. + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -558,14 +581,14 @@ def begin_update( parameters: Union[_models.ClusterUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Cluster]: - """Updates an existing RedisEnterprise cluster. + """Updates an existing Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cluster_name: The name of the Redis Enterprise cluster. Required. :type cluster_name: str - :param parameters: Parameters supplied to the Update RedisEnterprise operation. Is either a + :param parameters: Parameters supplied to the Update Redis Enterprise operation. Is either a ClusterUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.redisenterprise.models.ClusterUpdate or IO[bytes] :return: An instance of LROPoller that returns either Cluster or the result of cls(response) @@ -593,10 +616,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -620,10 +644,8 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -635,7 +657,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -645,10 +667,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -656,16 +678,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a RedisEnterprise cache cluster. + """Deletes a Redis Enterprise cache cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -685,7 +722,7 @@ def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -694,6 +731,7 @@ def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: An params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -719,7 +757,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- @distributed_trace def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: - """Gets information about a RedisEnterprise cluster. + """Gets information about a Redis Enterprise cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -730,7 +768,7 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.redisenterprise.models.Cluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,7 +790,6 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -767,7 +804,7 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -776,7 +813,7 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: - """Lists all RedisEnterprise clusters in a resource group. + """Lists all Redis Enterprise clusters in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -791,7 +828,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -809,7 +846,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -825,7 +861,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -857,7 +892,7 @@ def get_next(next_link=None): @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: - """Gets all RedisEnterprise clusters in the specified subscription. + """Lists all Redis Enterprise clusters in the specified subscription. :return: An iterator like instance of either Cluster or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redisenterprise.models.Cluster] @@ -869,7 +904,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +921,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -902,7 +936,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_list.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_list.py index e889ec129423..3336773c81a6 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_list.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/OperationsList.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_status_get.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_status_get.py index 2606b8de6d2b..716bd4c4692f 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_status_get.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/operations_status_get.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.operations_status.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/OperationsStatusGet.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/OperationsStatusGet.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_create_update.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_create_update.py new file mode 100644 index 000000000000..8e4fef2298b5 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_create_update.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redisenterprise +# USAGE + python redis_enterprise_access_policy_assignment_create_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = RedisEnterpriseManagementClient( + credential=DefaultAzureCredential(), + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", + ) + + response = client.access_policy_assignment.begin_create_update( + resource_group_name="rg1", + cluster_name="cache1", + database_name="default", + access_policy_assignment_name="defaultTestEntraApp1", + parameters={ + "properties": {"accessPolicyName": "default", "user": {"objectId": "6497c918-11ad-41e7-1b0f-7c518a87d0b0"}} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentCreateUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_delete.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_delete.py new file mode 100644 index 000000000000..59361df0c0c2 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redisenterprise +# USAGE + python redis_enterprise_access_policy_assignment_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = RedisEnterpriseManagementClient( + credential=DefaultAzureCredential(), + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", + ) + + client.access_policy_assignment.begin_delete( + resource_group_name="rg1", + cluster_name="cache1", + database_name="default", + access_policy_assignment_name="defaultTestEntraApp1", + ).result() + + +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_get.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_get.py new file mode 100644 index 000000000000..bc9c3406868b --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignment_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redisenterprise +# USAGE + python redis_enterprise_access_policy_assignment_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = RedisEnterpriseManagementClient( + credential=DefaultAzureCredential(), + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", + ) + + response = client.access_policy_assignment.get( + resource_group_name="rg1", + cluster_name="cache1", + database_name="default", + access_policy_assignment_name="accessPolicyAssignmentName1", + ) + print(response) + + +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json +if __name__ == "__main__": + main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignments_list.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignments_list.py new file mode 100644 index 000000000000..560e50f95f82 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_access_policy_assignments_list.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redisenterprise +# USAGE + python redis_enterprise_access_policy_assignments_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = RedisEnterpriseManagementClient( + credential=DefaultAzureCredential(), + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", + ) + + response = client.access_policy_assignment.list( + resource_group_name="rg1", + cluster_name="cache1", + database_name="default", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentsList.json +if __name__ == "__main__": + main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_create.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_create.py index ba95511ea8bb..dfe726740a32 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_create.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.redis_enterprise.begin_create( @@ -63,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseCreate.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseCreate.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create.py index 295c38e51b51..2ae500b7f0dc 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.begin_create( @@ -38,6 +36,7 @@ def main(): database_name="default", parameters={ "properties": { + "accessKeysAuthentication": "Enabled", "clientProtocol": "Encrypted", "clusteringPolicy": "EnterpriseCluster", "deferUpgrade": "NotDeferred", @@ -55,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesCreate.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesCreate.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create_with_geo_replication.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create_with_geo_replication.py index 17589215680c..980cfb56a759 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create_with_geo_replication.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_create_with_geo_replication.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid1", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.begin_create( @@ -38,6 +36,7 @@ def main(): database_name="default", parameters={ "properties": { + "accessKeysAuthentication": "Enabled", "clientProtocol": "Encrypted", "clusteringPolicy": "EnterpriseCluster", "evictionPolicy": "NoEviction", @@ -45,10 +44,10 @@ def main(): "groupNickname": "groupName", "linkedDatabases": [ { - "id": "/subscriptions/subid1/resourceGroups/rg1/providers/Microsoft.Cache/redisEnterprise/cache1/databases/default" + "id": "/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f/resourceGroups/rg1/providers/Microsoft.Cache/redisEnterprise/cache1/databases/default" }, { - "id": "/subscriptions/subid2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" + "id": "/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8e/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" }, ], }, @@ -59,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesCreateWithGeoReplication.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesCreateWithGeoReplication.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_delete.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_delete.py index df56f41e4a87..3aafad90049a 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_delete.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_delete.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesDelete.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesDelete.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_export.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_export.py index 908458924a7b..ea450c7196d7 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_export.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_export.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_export( @@ -40,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesExport.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesExport.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_flush.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_flush.py index 58bce67ae9d7..07b26f0ebd28 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_flush.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_flush.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_flush( @@ -38,12 +36,12 @@ def main(): database_name="default", parameters={ "ids": [ - "/subscriptions/subid2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" + "/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" ] }, ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesFlush.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesFlush.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_link.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_link.py index 90d8c842a442..f5f89301555a 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_link.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_link.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -50,6 +48,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesForceLink.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesForceLink.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_unlink.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_unlink.py index 2494edd29bac..ba1db1f41975 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_unlink.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_force_unlink.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_force_unlink( @@ -38,12 +36,12 @@ def main(): database_name="default", parameters={ "ids": [ - "/subscriptions/subid2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" + "/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default" ] }, ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesForceUnlink.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesForceUnlink.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_get.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_get.py index ea994e4c21d3..c9d741cd56b5 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_get.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_get.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesGet.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesGet.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_import.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_import.py index eab72f80ac8d..27e0b4f483a2 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_import.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_import_method( @@ -45,6 +43,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesImport.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesImport.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_by_cluster.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_by_cluster.py index 4a5feb7fb525..7c7c9d4648c6 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_by_cluster.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_by_cluster.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.list_by_cluster( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesListByCluster.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesListByCluster.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_keys.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_keys.py index 3c92b6da1a7a..b82d05905189 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_keys.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_list_keys.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.list_keys( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesListKeys.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesListKeys.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_regenerate_key.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_regenerate_key.py index 32a28f917256..3358fd7c4426 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_regenerate_key.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_regenerate_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.begin_regenerate_key( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesRegenerateKey.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_update.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_update.py index 6566ea72a7ad..6c4693d1cbe6 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_update.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.databases.begin_update( @@ -38,6 +36,7 @@ def main(): database_name="default", parameters={ "properties": { + "accessKeysAuthentication": "Enabled", "clientProtocol": "Encrypted", "evictionPolicy": "AllKeysLRU", "persistence": {"rdbEnabled": True, "rdbFrequency": "12h"}, @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesUpdate.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesUpdate.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_upgrade_db_redis_version.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_upgrade_db_redis_version.py index 9f137307d1d0..ad25605f6eaf 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_upgrade_db_redis_version.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_databases_upgrade_db_redis_version.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.databases.begin_upgrade_db_redis_version( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDatabasesUpgradeDBRedisVersion.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesUpgradeDBRedisVersion.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete.py index 32b4faecf61c..fa1b8f2453d9 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.redis_enterprise.begin_delete( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDelete.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDelete.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete_private_endpoint_connection.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete_private_endpoint_connection.py index e729eb0432c8..7cc5fd8213d3 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete_private_endpoint_connection.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_delete_private_endpoint_connection.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) client.private_endpoint_connections.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseDeletePrivateEndpointConnection.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get.py index 8bf14030b372..47af334ebb66 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.redis_enterprise.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseGet.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get_private_endpoint_connection.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get_private_endpoint_connection.py index 79147f1b680f..15857dae1749 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get_private_endpoint_connection.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_get_private_endpoint_connection.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.private_endpoint_connections.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseGetPrivateEndpointConnection.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list.py index 2b889155c54b..c80ddda19b8d 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.redis_enterprise.list() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseList.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseList.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_by_resource_group.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_by_resource_group.py index d79e03f66e03..259e0f87123d 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_by_resource_group.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_by_resource_group.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.redis_enterprise.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseListByResourceGroup.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_endpoint_connections.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_endpoint_connections.py index cb33ee3fd8ba..34cd59ea442f 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_endpoint_connections.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_endpoint_connections.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.private_endpoint_connections.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseListPrivateEndpointConnections.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListPrivateEndpointConnections.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_link_resources.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_link_resources.py index c9d507709bac..3b96921a9fb7 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_link_resources.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_list_private_link_resources.py @@ -27,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.private_link_resources.list_by_cluster( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseListPrivateLinkResources.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_put_private_endpoint_connection.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_put_private_endpoint_connection.py index 26478a798018..e7f62637cd99 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_put_private_endpoint_connection.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_put_private_endpoint_connection.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.private_endpoint_connections.begin_put( @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_update.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_update.py index f11f580d45c5..0f572d902087 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_update.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_samples/redis_enterprise_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient @@ -29,7 +27,7 @@ def main(): client = RedisEnterpriseManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f", ) response = client.redis_enterprise.begin_update( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-03-01-preview/examples/RedisEnterpriseUpdate.json +# x-ms-original-file: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseUpdate.json if __name__ == "__main__": main() diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/conftest.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/conftest.py new file mode 100644 index 000000000000..3880ade3dfe4 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/conftest.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + redisenterprisemanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + redisenterprisemanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + redisenterprisemanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + redisenterprisemanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=redisenterprisemanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=redisenterprisemanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=redisenterprisemanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=redisenterprisemanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations.py new file mode 100644 index 000000000000..01fff549bff7 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementAccessPolicyAssignmentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_update(self, resource_group): + response = self.client.access_policy_assignment.begin_create_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + parameters={ + "accessPolicyName": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "user": {"objectId": "str"}, + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.access_policy_assignment.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.access_policy_assignment.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.access_policy_assignment.list( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations_async.py new file mode 100644 index 000000000000..17f930d3f25d --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_access_policy_assignment_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementAccessPolicyAssignmentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_update(self, resource_group): + response = await ( + await self.client.access_policy_assignment.begin_create_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + parameters={ + "accessPolicyName": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "user": {"objectId": "str"}, + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.access_policy_assignment.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.access_policy_assignment.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + access_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.access_policy_assignment.list( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations.py new file mode 100644 index 000000000000..55d71791c0e5 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations.py @@ -0,0 +1,232 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementDatabasesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.databases.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.databases.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "accessKeysAuthentication": "str", + "clientProtocol": "str", + "clusteringPolicy": "str", + "deferUpgrade": "str", + "evictionPolicy": "str", + "geoReplication": {"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + "id": "str", + "modules": [{"name": "str", "args": "str", "version": "str"}], + "name": "str", + "persistence": {"aofEnabled": bool, "aofFrequency": "str", "rdbEnabled": bool, "rdbFrequency": "str"}, + "port": 0, + "provisioningState": "str", + "redisVersion": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.databases.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "accessKeysAuthentication": "str", + "clientProtocol": "str", + "clusteringPolicy": "str", + "deferUpgrade": "str", + "evictionPolicy": "str", + "geoReplication": {"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + "modules": [{"name": "str", "args": "str", "version": "str"}], + "persistence": {"aofEnabled": bool, "aofFrequency": "str", "rdbEnabled": bool, "rdbFrequency": "str"}, + "port": 0, + "provisioningState": "str", + "redisVersion": "str", + "resourceState": "str", + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.databases.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.databases.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_keys(self, resource_group): + response = self.client.databases.list_keys( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_regenerate_key(self, resource_group): + response = self.client.databases.begin_regenerate_key( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"keyType": "str"}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_import_method(self, resource_group): + response = self.client.databases.begin_import_method( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"sasUris": ["str"]}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_export(self, resource_group): + response = self.client.databases.begin_export( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"sasUri": "str"}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_force_unlink(self, resource_group): + response = self.client.databases.begin_force_unlink( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"ids": ["str"]}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_force_link_to_replication_group(self, resource_group): + response = self.client.databases.begin_force_link_to_replication_group( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_flush(self, resource_group): + response = self.client.databases.begin_flush( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"ids": ["str"]}, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_upgrade_db_redis_version(self, resource_group): + response = self.client.databases.begin_upgrade_db_redis_version( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations_async.py new file mode 100644 index 000000000000..17c9934b83d9 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_databases_operations_async.py @@ -0,0 +1,263 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.databases.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.databases.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "accessKeysAuthentication": "str", + "clientProtocol": "str", + "clusteringPolicy": "str", + "deferUpgrade": "str", + "evictionPolicy": "str", + "geoReplication": {"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + "id": "str", + "modules": [{"name": "str", "args": "str", "version": "str"}], + "name": "str", + "persistence": { + "aofEnabled": bool, + "aofFrequency": "str", + "rdbEnabled": bool, + "rdbFrequency": "str", + }, + "port": 0, + "provisioningState": "str", + "redisVersion": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.databases.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "accessKeysAuthentication": "str", + "clientProtocol": "str", + "clusteringPolicy": "str", + "deferUpgrade": "str", + "evictionPolicy": "str", + "geoReplication": {"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + "modules": [{"name": "str", "args": "str", "version": "str"}], + "persistence": { + "aofEnabled": bool, + "aofFrequency": "str", + "rdbEnabled": bool, + "rdbFrequency": "str", + }, + "port": 0, + "provisioningState": "str", + "redisVersion": "str", + "resourceState": "str", + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.databases.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.databases.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_keys(self, resource_group): + response = await self.client.databases.list_keys( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_regenerate_key(self, resource_group): + response = await ( + await self.client.databases.begin_regenerate_key( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"keyType": "str"}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_import_method(self, resource_group): + response = await ( + await self.client.databases.begin_import_method( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"sasUris": ["str"]}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_export(self, resource_group): + response = await ( + await self.client.databases.begin_export( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"sasUri": "str"}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_force_unlink(self, resource_group): + response = await ( + await self.client.databases.begin_force_unlink( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"ids": ["str"]}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_force_link_to_replication_group(self, resource_group): + response = await ( + await self.client.databases.begin_force_link_to_replication_group( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"groupNickname": "str", "linkedDatabases": [{"id": "str", "state": "str"}]}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_flush(self, resource_group): + response = await ( + await self.client.databases.begin_flush( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"ids": ["str"]}, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_upgrade_db_redis_version(self, resource_group): + response = await ( + await self.client.databases.begin_upgrade_db_redis_version( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations.py new file mode 100644 index 000000000000..197828d50e5b --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_async.py new file mode 100644 index 000000000000..c6f7f2b9c06d --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations.py new file mode 100644 index 000000000000..6d2cbea22e7c --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementOperationsStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operations_status.get( + location="str", + operation_id="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations_async.py new file mode 100644 index 000000000000..df578eedf1ad --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_operations_status_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementOperationsStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operations_status.get( + location="str", + operation_id="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..15d8367f20cd --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_put(self, resource_group): + response = self.client.private_endpoint_connections.begin_put( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + properties={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..29b4189507e1 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_put(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_put( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + properties={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations.py new file mode 100644 index 000000000000..34372b6327a6 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.private_link_resources.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..058e8b6e4fea --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_private_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.private_link_resources.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations.py new file mode 100644 index 000000000000..0a2a0ba58741 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations.py @@ -0,0 +1,167 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementRedisEnterpriseOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.redis_enterprise.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "capacity": 0}, + "encryption": { + "customerManagedKeyEncryption": { + "keyEncryptionKeyIdentity": {"identityType": "str", "userAssignedIdentityResourceId": "str"}, + "keyEncryptionKeyUrl": "str", + } + }, + "highAvailability": "str", + "hostName": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "minimumTlsVersion": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "redisVersion": "str", + "redundancyMode": "str", + "resourceState": "str", + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.redis_enterprise.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "encryption": { + "customerManagedKeyEncryption": { + "keyEncryptionKeyIdentity": {"identityType": "str", "userAssignedIdentityResourceId": "str"}, + "keyEncryptionKeyUrl": "str", + } + }, + "highAvailability": "str", + "hostName": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "minimumTlsVersion": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "redisVersion": "str", + "redundancyMode": "str", + "resourceState": "str", + "sku": {"name": "str", "capacity": 0}, + "tags": {"str": "str"}, + }, + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.redis_enterprise.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.redis_enterprise.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.redis_enterprise.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.redis_enterprise.list( + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations_async.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations_async.py new file mode 100644 index 000000000000..dc424f716df0 --- /dev/null +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/generated_tests/test_redis_enterprise_management_redis_enterprise_operations_async.py @@ -0,0 +1,180 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.redisenterprise.aio import RedisEnterpriseManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestRedisEnterpriseManagementRedisEnterpriseOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(RedisEnterpriseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.redis_enterprise.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "capacity": 0}, + "encryption": { + "customerManagedKeyEncryption": { + "keyEncryptionKeyIdentity": { + "identityType": "str", + "userAssignedIdentityResourceId": "str", + }, + "keyEncryptionKeyUrl": "str", + } + }, + "highAvailability": "str", + "hostName": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "minimumTlsVersion": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "redisVersion": "str", + "redundancyMode": "str", + "resourceState": "str", + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.redis_enterprise.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "encryption": { + "customerManagedKeyEncryption": { + "keyEncryptionKeyIdentity": { + "identityType": "str", + "userAssignedIdentityResourceId": "str", + }, + "keyEncryptionKeyUrl": "str", + } + }, + "highAvailability": "str", + "hostName": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "minimumTlsVersion": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "redisVersion": "str", + "redundancyMode": "str", + "resourceState": "str", + "sku": {"name": "str", "capacity": 0}, + "tags": {"str": "str"}, + }, + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.redis_enterprise.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.redis_enterprise.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.redis_enterprise.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.redis_enterprise.list( + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/redisenterprise/azure-mgmt-redisenterprise/setup.py b/sdk/redisenterprise/azure-mgmt-redisenterprise/setup.py index 6a41e36f1fe2..8d0e56c1a8aa 100644 --- a/sdk/redisenterprise/azure-mgmt-redisenterprise/setup.py +++ b/sdk/redisenterprise/azure-mgmt-redisenterprise/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],