diff --git a/sdk/redis/azure-mgmt-redis/_meta.json b/sdk/redis/azure-mgmt-redis/_meta.json index 5caa785f4e00..580b9eafd7bb 100644 --- a/sdk/redis/azure-mgmt-redis/_meta.json +++ b/sdk/redis/azure-mgmt-redis/_meta.json @@ -1,11 +1,11 @@ { - "commit": "c183bb012de8e9e1d0d2e67a0994748df4747d2c", + "commit": "d0a8b1c13b21cebacd0fbcdbd753ddfe13442d70", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.12", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/redis/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.4.12 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/redis/resource-manager/readme.md --generate-sample=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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/redis/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py index ad5e1f2b8823..1226e8b1fb88 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py @@ -27,17 +27,16 @@ class RedisManagementClientConfiguration(Configuration): # pylint: disable=too- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-08-01". 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: super(RedisManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01") + api_version: str = kwargs.pop("api_version", "2023-08-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_redis_management_client.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_redis_management_client.py index 1f7324775c71..e6c2e0df7900 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_redis_management_client.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_redis_management_client.py @@ -16,6 +16,8 @@ from ._configuration import RedisManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + AccessPolicyAssignmentOperations, + AccessPolicyOperations, AsyncOperationStatusOperations, FirewallRulesOperations, LinkedServerOperations, @@ -51,14 +53,17 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo :vartype private_link_resources: azure.mgmt.redis.operations.PrivateLinkResourcesOperations :ivar async_operation_status: AsyncOperationStatusOperations operations :vartype async_operation_status: azure.mgmt.redis.operations.AsyncOperationStatusOperations + :ivar access_policy: AccessPolicyOperations operations + :vartype access_policy: azure.mgmt.redis.operations.AccessPolicyOperations + :ivar access_policy_assignment: AccessPolicyAssignmentOperations operations + :vartype access_policy_assignment: azure.mgmt.redis.operations.AccessPolicyAssignmentOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :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 "2023-04-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -95,6 +100,10 @@ def __init__( self.async_operation_status = AsyncOperationStatusOperations( self._client, self._config, self._serialize, self._deserialize ) + self.access_policy = AccessPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_policy_assignment = AccessPolicyAssignmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py index 842ae727fbbc..4bae2292227b 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py index 9179afc8fe9f..dc6920075e88 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "14.2.0" +VERSION = "12.0.0b1" diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_configuration.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_configuration.py index 692af2a8ae5e..134a969e829e 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_configuration.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_configuration.py @@ -27,17 +27,16 @@ class RedisManagementClientConfiguration(Configuration): # pylint: disable=too- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-08-01". 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: super(RedisManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01") + api_version: str = kwargs.pop("api_version", "2023-08-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_redis_management_client.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_redis_management_client.py index 6176a6560bb7..2004e81fc59c 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_redis_management_client.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_redis_management_client.py @@ -16,6 +16,8 @@ from .._serialization import Deserializer, Serializer from ._configuration import RedisManagementClientConfiguration from .operations import ( + AccessPolicyAssignmentOperations, + AccessPolicyOperations, AsyncOperationStatusOperations, FirewallRulesOperations, LinkedServerOperations, @@ -51,14 +53,18 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo :vartype private_link_resources: azure.mgmt.redis.aio.operations.PrivateLinkResourcesOperations :ivar async_operation_status: AsyncOperationStatusOperations operations :vartype async_operation_status: azure.mgmt.redis.aio.operations.AsyncOperationStatusOperations + :ivar access_policy: AccessPolicyOperations operations + :vartype access_policy: azure.mgmt.redis.aio.operations.AccessPolicyOperations + :ivar access_policy_assignment: AccessPolicyAssignmentOperations operations + :vartype access_policy_assignment: + azure.mgmt.redis.aio.operations.AccessPolicyAssignmentOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :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 "2023-04-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2023-08-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -95,6 +101,10 @@ def __init__( self.async_operation_status = AsyncOperationStatusOperations( self._client, self._config, self._serialize, self._deserialize ) + self.access_policy = AccessPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_policy_assignment = AccessPolicyAssignmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/__init__.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/__init__.py index 8237f395ab5c..4d3740bcc656 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/__init__.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/__init__.py @@ -14,6 +14,8 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._async_operation_status_operations import AsyncOperationStatusOperations +from ._access_policy_operations import AccessPolicyOperations +from ._access_policy_assignment_operations import AccessPolicyAssignmentOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -28,6 +30,8 @@ "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", "AsyncOperationStatusOperations", + "AccessPolicyOperations", + "AccessPolicyAssignmentOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_assignment_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_assignment_operations.py new file mode 100644 index 000000000000..816765f492d4 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_assignment_operations.py @@ -0,0 +1,591 @@ +# pylint: disable=too-many-lines +# 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 +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, 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, + 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.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 ..._vendor import _convert_request +from ...operations._access_policy_assignment_operations import ( + build_create_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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.redis.aio.RedisManagementClient`'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, + cache_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO], + **kwargs: Any + ) -> _models.RedisCacheAccessPolicyAssignment: + error_map = { + 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[_models.RedisCacheAccessPolicyAssignment] = 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, "RedisCacheAccessPolicyAssignment") + + request = build_create_update_request( + resource_group_name=resource_group_name, + cache_name=cache_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, + template_url=self._create_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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("RedisCacheAccessPolicyAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: _models.RedisCacheAccessPolicyAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicyAssignment or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicyAssignment or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Is either a RedisCacheAccessPolicyAssignment type or a IO type. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicyAssignment or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :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.RedisCacheAccessPolicyAssignment] = 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, + cache_name=cache_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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> None: + error_map = { + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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, 202, 204]: + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the access policy assignment from a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either 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( # type: ignore + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> _models.RedisCacheAccessPolicyAssignment: + """Gets the list of assignments for an access policy of a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RedisCacheAccessPolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.RedisCacheAccessPolicyAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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("RedisCacheAccessPolicyAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RedisCacheAccessPolicyAssignment"]: + """Gets the list of access policy assignments associated with this redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RedisCacheAccessPolicyAssignment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :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.RedisCacheAccessPolicyAssignmentList] = kwargs.pop("cls", None) + + error_map = { + 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, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyAssignmentList", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments" + } diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_operations.py new file mode 100644 index 000000000000..ab40b45edd59 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_operations.py @@ -0,0 +1,591 @@ +# pylint: disable=too-many-lines +# 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 +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, 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, + 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.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 ..._vendor import _convert_request +from ...operations._access_policy_operations import ( + build_create_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redis.aio.RedisManagementClient`'s + :attr:`access_policy` 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, + cache_name: str, + access_policy_name: str, + parameters: Union[_models.RedisCacheAccessPolicy, IO], + **kwargs: Any + ) -> _models.RedisCacheAccessPolicy: + error_map = { + 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[_models.RedisCacheAccessPolicy] = 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, "RedisCacheAccessPolicy") + + request = build_create_update_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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("RedisCacheAccessPolicy", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("RedisCacheAccessPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: _models.RedisCacheAccessPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicy or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicy or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: Union[_models.RedisCacheAccessPolicy, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Is either + a RedisCacheAccessPolicy type or a IO type. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RedisCacheAccessPolicy or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :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.RedisCacheAccessPolicy] = 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, + cache_name=cache_name, + access_policy_name=access_policy_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicy", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> None: + error_map = { + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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, 202, 204]: + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the access policy from a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either 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( # type: ignore + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> _models.RedisCacheAccessPolicy: + """Gets the detailed information about an access policy of a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RedisCacheAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.redis.models.RedisCacheAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.RedisCacheAccessPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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("RedisCacheAccessPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RedisCacheAccessPolicy"]: + """Gets the list of access policies associated with this redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RedisCacheAccessPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :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.RedisCacheAccessPolicyList] = kwargs.pop("cls", None) + + error_map = { + 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, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyList", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies" + } diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_firewall_rules_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_firewall_rules_operations.py index e9a168c61073..bdd09e54b91e 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_firewall_rules_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_firewall_rules_operations.py @@ -65,7 +65,8 @@ def list( ) -> AsyncIterable["_models.RedisFirewallRule"]: """Gets all firewall rules in the specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -163,7 +164,8 @@ async def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -194,7 +196,8 @@ async def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -223,7 +226,8 @@ async def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -312,7 +316,8 @@ async def get( ) -> _models.RedisFirewallRule: """Gets a single firewall rule in a specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -379,7 +384,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a single firewall rule in a specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_linked_server_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_linked_server_operations.py index 59a6940e8ee7..74a3a5f90084 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_linked_server_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_linked_server_operations.py @@ -148,7 +148,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -188,7 +189,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -226,7 +228,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -344,8 +347,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}" @@ -357,7 +364,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes the linked server from a redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -426,7 +434,8 @@ async def get( ) -> _models.RedisLinkedServerWithProperties: """Gets the detailed information about a linked server of a redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -493,7 +502,8 @@ def list( ) -> AsyncIterable["_models.RedisLinkedServerWithProperties"]: """Gets the list of linked servers associated with this redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_patch_schedules_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_patch_schedules_operations.py index 82766ff08f74..ae765ea15c01 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_patch_schedules_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_patch_schedules_operations.py @@ -65,7 +65,8 @@ def list_by_redis_resource( ) -> AsyncIterable["_models.RedisPatchSchedule"]: """Gets all patch schedules in the specified redis cache (there is only one). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -163,7 +164,8 @@ async def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -194,7 +196,8 @@ async def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -223,7 +226,8 @@ async def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -313,7 +317,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes the patching schedule of a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -377,7 +382,8 @@ async def get( ) -> _models.RedisPatchSchedule: """Gets the patching schedule of a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_endpoint_connections_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_endpoint_connections_operations.py index afb591e14206..7963ab68ce83 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_endpoint_connections_operations.py @@ -67,7 +67,8 @@ def list( ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -160,7 +161,8 @@ async def get( ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -309,7 +311,8 @@ async def begin_put( ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -348,7 +351,8 @@ async def begin_put( ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -385,7 +389,8 @@ async def begin_put( ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -466,7 +471,8 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes the specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_link_resources_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_link_resources_operations.py index 705f54fd2c92..681c0bcc9ff4 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_link_resources_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_private_link_resources_operations.py @@ -58,7 +58,8 @@ def list_by_redis_cache( ) -> AsyncIterable["_models.PrivateLinkResource"]: """Gets the private link resources that need to be created for a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_redis_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_redis_operations.py index bdffcbfbd176..e8721ee715f1 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_redis_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_redis_operations.py @@ -36,6 +36,7 @@ build_create_request, build_delete_request, build_export_data_request, + build_flush_cache_request, build_force_reboot_request, build_get_request, build_import_data_request, @@ -189,7 +190,8 @@ def list_upgrade_notifications( ) -> AsyncIterable["_models.UpgradeNotification"]: """Gets any upgrade notifications for a Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -357,7 +359,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -392,7 +395,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -421,7 +425,8 @@ async def begin_create( ) -> AsyncLROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -572,7 +577,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -607,7 +613,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -636,7 +643,8 @@ async def begin_update( ) -> AsyncLROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -759,7 +767,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements async def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -822,7 +831,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.RedisResource: """Gets a Redis cache (resource description). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -884,7 +894,8 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _mode def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.RedisResource"]: """Lists all Redis caches in a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RedisResource or the result of cls(response) @@ -1052,7 +1063,8 @@ async def list_keys(self, resource_group_name: str, name: str, **kwargs: Any) -> """Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1123,7 +1135,8 @@ async def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1151,7 +1164,8 @@ async def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1177,7 +1191,8 @@ async def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1266,7 +1281,8 @@ async def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1294,7 +1310,8 @@ async def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1316,7 +1333,8 @@ async def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1464,7 +1482,8 @@ async def begin_import_data( ) -> AsyncLROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1498,7 +1517,8 @@ async def begin_import_data( ) -> AsyncLROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1526,7 +1546,8 @@ async def begin_import_data( ) -> AsyncLROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1666,7 +1687,8 @@ async def begin_export_data( ) -> AsyncLROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1700,7 +1722,8 @@ async def begin_export_data( ) -> AsyncLROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1728,7 +1751,8 @@ async def begin_export_data( ) -> AsyncLROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1795,3 +1819,147 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_export_data.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/export" } + + async def _flush_cache_initial( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + request = build_flush_cache_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._flush_cache_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 202]: + 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 + response_headers = {} + if response.status_code == 200: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + 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") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _flush_cache_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/flush" + } + + @distributed_trace_async + async def begin_flush_cache( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """Deletes all of the keys in a cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redis.models.OperationStatusResult] + :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.OperationStatusResult] = 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._flush_cache_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_flush_cache.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/flush" + } diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/__init__.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/__init__.py index 6828a78bbab3..f0b603c2a559 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/__init__.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/__init__.py @@ -9,7 +9,6 @@ from ._models_py3 import CheckNameAvailabilityParameters from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorDetailAutoGenerated from ._models_py3 import ErrorResponse from ._models_py3 import ExportRDBParameters from ._models_py3 import ImportRDBParameters @@ -28,6 +27,10 @@ from ._models_py3 import PrivateLinkServiceConnectionState from ._models_py3 import ProxyResource from ._models_py3 import RedisAccessKeys +from ._models_py3 import RedisCacheAccessPolicy +from ._models_py3 import RedisCacheAccessPolicyAssignment +from ._models_py3 import RedisCacheAccessPolicyAssignmentList +from ._models_py3 import RedisCacheAccessPolicyList from ._models_py3 import RedisCommonProperties from ._models_py3 import RedisCommonPropertiesRedisConfiguration from ._models_py3 import RedisCreateParameters @@ -59,6 +62,9 @@ from ._models_py3 import UpgradeNotification from ._models_py3 import UserAssignedIdentity +from ._redis_management_client_enums import AccessPolicyAssignmentProvisioningState +from ._redis_management_client_enums import AccessPolicyProvisioningState +from ._redis_management_client_enums import AccessPolicyType from ._redis_management_client_enums import DayOfWeek from ._redis_management_client_enums import DefaultName from ._redis_management_client_enums import ManagedServiceIdentityType @@ -72,6 +78,7 @@ from ._redis_management_client_enums import SkuFamily from ._redis_management_client_enums import SkuName from ._redis_management_client_enums import TlsVersion +from ._redis_management_client_enums import UpdateChannel from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -80,7 +87,6 @@ "CheckNameAvailabilityParameters", "ErrorAdditionalInfo", "ErrorDetail", - "ErrorDetailAutoGenerated", "ErrorResponse", "ExportRDBParameters", "ImportRDBParameters", @@ -99,6 +105,10 @@ "PrivateLinkServiceConnectionState", "ProxyResource", "RedisAccessKeys", + "RedisCacheAccessPolicy", + "RedisCacheAccessPolicyAssignment", + "RedisCacheAccessPolicyAssignmentList", + "RedisCacheAccessPolicyList", "RedisCommonProperties", "RedisCommonPropertiesRedisConfiguration", "RedisCreateParameters", @@ -129,6 +139,9 @@ "TrackedResource", "UpgradeNotification", "UserAssignedIdentity", + "AccessPolicyAssignmentProvisioningState", + "AccessPolicyProvisioningState", + "AccessPolicyType", "DayOfWeek", "DefaultName", "ManagedServiceIdentityType", @@ -142,6 +155,7 @@ "SkuFamily", "SkuName", "TlsVersion", + "UpdateChannel", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_models_py3.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_models_py3.py index 6b145d9757df..11053b8cbe24 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_models_py3.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_models_py3.py @@ -123,49 +123,6 @@ def __init__(self, **kwargs: Any) -> None: self.additional_info = None -class ErrorDetailAutoGenerated(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.redis.models.ErrorDetailAutoGenerated] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.redis.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetailAutoGenerated]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). @@ -524,7 +481,7 @@ class OperationStatusResult(_serialization.Model): :ivar operations: The operations list. :vartype operations: list[~azure.mgmt.redis.models.OperationStatusResult] :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.redis.models.ErrorDetailAutoGenerated + :vartype error: ~azure.mgmt.redis.models.ErrorDetail """ _validation = { @@ -540,7 +497,7 @@ class OperationStatusResult(_serialization.Model): "start_time": {"key": "startTime", "type": "iso-8601"}, "end_time": {"key": "endTime", "type": "iso-8601"}, "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( @@ -553,7 +510,7 @@ def __init__( start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, operations: Optional[List["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetailAutoGenerated"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs: Any ) -> None: """ @@ -572,7 +529,7 @@ def __init__( :keyword operations: The operations list. :paramtype operations: list[~azure.mgmt.redis.models.OperationStatusResult] :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.redis.models.ErrorDetailAutoGenerated + :paramtype error: ~azure.mgmt.redis.models.ErrorDetail """ super().__init__(**kwargs) self.id = id @@ -605,7 +562,7 @@ class OperationStatus(OperationStatusResult): :ivar operations: The operations list. :vartype operations: list[~azure.mgmt.redis.models.OperationStatusResult] :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.redis.models.ErrorDetailAutoGenerated + :vartype error: ~azure.mgmt.redis.models.ErrorDetail :ivar properties: Additional properties from RP, only when operation is successful. :vartype properties: dict[str, any] """ @@ -623,7 +580,7 @@ class OperationStatus(OperationStatusResult): "start_time": {"key": "startTime", "type": "iso-8601"}, "end_time": {"key": "endTime", "type": "iso-8601"}, "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, + "error": {"key": "error", "type": "ErrorDetail"}, "properties": {"key": "properties", "type": "{object}"}, } @@ -637,7 +594,7 @@ def __init__( start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, operations: Optional[List["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetailAutoGenerated"] = None, + error: Optional["_models.ErrorDetail"] = None, properties: Optional[Dict[str, Any]] = None, **kwargs: Any ) -> None: @@ -657,7 +614,7 @@ def __init__( :keyword operations: The operations list. :paramtype operations: list[~azure.mgmt.redis.models.OperationStatusResult] :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.redis.models.ErrorDetailAutoGenerated + :paramtype error: ~azure.mgmt.redis.models.ErrorDetail :keyword properties: Additional properties from RP, only when operation is successful. :paramtype properties: dict[str, any] """ @@ -994,6 +951,189 @@ def __init__(self, **kwargs: Any) -> None: self.secondary_key = None +class RedisCacheAccessPolicy(ProxyResource): + """Response to get/put access policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar provisioning_state: Provisioning state of access policy. Known values are: "Updating", + "Succeeded", "Deleting", "Deleted", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.redis.models.AccessPolicyProvisioningState + :ivar type_properties_type: Built-In or Custom access policy. Known values are: "Custom" and + "BuiltIn". + :vartype type_properties_type: str or ~azure.mgmt.redis.models.AccessPolicyType + :ivar permissions: Permissions for the access policy. Learn how to configure permissions at + https://aka.ms/redis/AADPreRequisites. + :vartype permissions: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "type_properties_type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "permissions": {"key": "properties.permissions", "type": "str"}, + } + + def __init__(self, *, permissions: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword permissions: Permissions for the access policy. Learn how to configure permissions at + https://aka.ms/redis/AADPreRequisites. + :paramtype permissions: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.type_properties_type = None + self.permissions = permissions + + +class RedisCacheAccessPolicyAssignment(ProxyResource): + """Response to an operation on access policy assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar provisioning_state: Provisioning state of an access policy assignment set. Known values + are: "Updating", "Succeeded", "Deleting", "Deleted", "Canceled", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.redis.models.AccessPolicyAssignmentProvisioningState + :ivar object_id: Object Id to assign access policy to. + :vartype object_id: str + :ivar object_id_alias: User friendly name for object id. Also represents username for token + based authentication. + :vartype object_id_alias: str + :ivar access_policy_name: The name of the access policy that is being assigned. + :vartype access_policy_name: str + """ + + _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"}, + "object_id": {"key": "properties.objectId", "type": "str"}, + "object_id_alias": {"key": "properties.objectIdAlias", "type": "str"}, + "access_policy_name": {"key": "properties.accessPolicyName", "type": "str"}, + } + + def __init__( + self, + *, + object_id: Optional[str] = None, + object_id_alias: Optional[str] = None, + access_policy_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword object_id: Object Id to assign access policy to. + :paramtype object_id: str + :keyword object_id_alias: User friendly name for object id. Also represents username for token + based authentication. + :paramtype object_id_alias: str + :keyword access_policy_name: The name of the access policy that is being assigned. + :paramtype access_policy_name: str + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.object_id = object_id + self.object_id_alias = object_id_alias + self.access_policy_name = access_policy_name + + +class RedisCacheAccessPolicyAssignmentList(_serialization.Model): + """List of access policies assignments (with properties) of a Redis cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of access policies assignments (with properties) of a Redis cache. + :vartype value: list[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :ivar next_link: Link for next set. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RedisCacheAccessPolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.RedisCacheAccessPolicyAssignment"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: List of access policies assignments (with properties) of a Redis cache. + :paramtype value: list[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class RedisCacheAccessPolicyList(_serialization.Model): + """List of access policies (with properties) of a Redis cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of access policies (with properties) of a Redis cache. + :vartype value: list[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :ivar next_link: Link for next set. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RedisCacheAccessPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.RedisCacheAccessPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of access policies (with properties) of a Redis cache. + :paramtype value: list[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + class RedisCommonProperties(_serialization.Model): """Create/Update/Get common properties of the redis cache. @@ -1023,6 +1163,11 @@ class RedisCommonProperties(_serialization.Model): endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel """ _attribute_map = { @@ -1035,6 +1180,7 @@ class RedisCommonProperties(_serialization.Model): "shard_count": {"key": "shardCount", "type": "int"}, "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "updateChannel", "type": "str"}, } def __init__( @@ -1049,6 +1195,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, **kwargs: Any ) -> None: """ @@ -1080,6 +1227,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel """ super().__init__(**kwargs) self.redis_configuration = redis_configuration @@ -1091,6 +1243,7 @@ def __init__( self.shard_count = shard_count self.minimum_tls_version = minimum_tls_version self.public_network_access = public_network_access + self.update_channel = update_channel class RedisCommonPropertiesRedisConfiguration(_serialization.Model): # pylint: disable=too-many-instance-attributes @@ -1145,6 +1298,9 @@ class RedisCommonPropertiesRedisConfiguration(_serialization.Model): # pylint: :ivar storage_subscription_id: SubscriptionId of the storage account for persistence (aof/rdb) using ManagedIdentity. :vartype storage_subscription_id: str + :ivar aad_enabled: Specifies whether AAD based authentication has been enabled or disabled for + the cache. + :vartype aad_enabled: str """ _validation = { @@ -1172,6 +1328,7 @@ class RedisCommonPropertiesRedisConfiguration(_serialization.Model): # pylint: "zonal_configuration": {"key": "zonal-configuration", "type": "str"}, "authnotrequired": {"key": "authnotrequired", "type": "str"}, "storage_subscription_id": {"key": "storage-subscription-id", "type": "str"}, + "aad_enabled": {"key": "aad-enabled", "type": "str"}, } def __init__( @@ -1192,6 +1349,7 @@ def __init__( preferred_data_persistence_auth_method: Optional[str] = None, authnotrequired: Optional[str] = None, storage_subscription_id: Optional[str] = None, + aad_enabled: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -1237,6 +1395,9 @@ def __init__( :keyword storage_subscription_id: SubscriptionId of the storage account for persistence (aof/rdb) using ManagedIdentity. :paramtype storage_subscription_id: str + :keyword aad_enabled: Specifies whether AAD based authentication has been enabled or disabled + for the cache. + :paramtype aad_enabled: str """ super().__init__(**kwargs) self.additional_properties = additional_properties @@ -1257,6 +1418,7 @@ def __init__( self.zonal_configuration = None self.authnotrequired = authnotrequired self.storage_subscription_id = storage_subscription_id + self.aad_enabled = aad_enabled class RedisCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes @@ -1298,6 +1460,11 @@ class RedisCreateParameters(_serialization.Model): # pylint: disable=too-many-i endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. Required. :vartype sku: ~azure.mgmt.redis.models.Sku :ivar subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -1335,6 +1502,7 @@ class RedisCreateParameters(_serialization.Model): # pylint: disable=too-many-i "shard_count": {"key": "properties.shardCount", "type": "int"}, "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "properties.updateChannel", "type": "str"}, "sku": {"key": "properties.sku", "type": "Sku"}, "subnet_id": {"key": "properties.subnetId", "type": "str"}, "static_ip": {"key": "properties.staticIP", "type": "str"}, @@ -1357,6 +1525,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, subnet_id: Optional[str] = None, static_ip: Optional[str] = None, **kwargs: Any @@ -1398,6 +1567,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. Required. :paramtype sku: ~azure.mgmt.redis.models.Sku :keyword subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -1422,6 +1596,7 @@ def __init__( self.shard_count = shard_count self.minimum_tls_version = minimum_tls_version self.public_network_access = public_network_access + self.update_channel = update_channel self.sku = sku self.subnet_id = subnet_id self.static_ip = static_ip @@ -1458,6 +1633,11 @@ class RedisCreateProperties(RedisCommonProperties): # pylint: disable=too-many- endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. Required. :vartype sku: ~azure.mgmt.redis.models.Sku :ivar subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -1487,6 +1667,7 @@ class RedisCreateProperties(RedisCommonProperties): # pylint: disable=too-many- "shard_count": {"key": "shardCount", "type": "int"}, "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "updateChannel", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "subnet_id": {"key": "subnetId", "type": "str"}, "static_ip": {"key": "staticIP", "type": "str"}, @@ -1505,6 +1686,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, subnet_id: Optional[str] = None, static_ip: Optional[str] = None, **kwargs: Any @@ -1538,6 +1720,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. Required. :paramtype sku: ~azure.mgmt.redis.models.Sku :keyword subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -1558,6 +1745,7 @@ def __init__( shard_count=shard_count, minimum_tls_version=minimum_tls_version, public_network_access=public_network_access, + update_channel=update_channel, **kwargs ) self.sku = sku @@ -2229,6 +2417,11 @@ class RedisProperties(RedisCreateProperties): # pylint: disable=too-many-instan endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. Required. :vartype sku: ~azure.mgmt.redis.models.Sku :ivar subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -2240,7 +2433,7 @@ class RedisProperties(RedisCreateProperties): # pylint: disable=too-many-instan :vartype static_ip: str :ivar provisioning_state: Redis instance provisioning status. Known values are: "Creating", "Deleting", "Disabled", "Failed", "Linking", "Provisioning", "RecoveringScaleFailure", - "Scaling", "Succeeded", "Unlinking", "Unprovisioning", and "Updating". + "Scaling", "Succeeded", "Unlinking", "Unprovisioning", "Updating", and "ConfiguringAAD". :vartype provisioning_state: str or ~azure.mgmt.redis.models.ProvisioningState :ivar host_name: Redis host name. :vartype host_name: str @@ -2286,6 +2479,7 @@ class RedisProperties(RedisCreateProperties): # pylint: disable=too-many-instan "shard_count": {"key": "shardCount", "type": "int"}, "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "updateChannel", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "subnet_id": {"key": "subnetId", "type": "str"}, "static_ip": {"key": "staticIP", "type": "str"}, @@ -2312,6 +2506,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, subnet_id: Optional[str] = None, static_ip: Optional[str] = None, **kwargs: Any @@ -2345,6 +2540,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. Required. :paramtype sku: ~azure.mgmt.redis.models.Sku :keyword subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -2365,6 +2565,7 @@ def __init__( shard_count=shard_count, minimum_tls_version=minimum_tls_version, public_network_access=public_network_access, + update_channel=update_channel, sku=sku, subnet_id=subnet_id, static_ip=static_ip, @@ -2549,6 +2750,11 @@ class RedisResource(TrackedResource): # pylint: disable=too-many-instance-attri endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. Required. :vartype sku: ~azure.mgmt.redis.models.Sku :ivar subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -2560,7 +2766,7 @@ class RedisResource(TrackedResource): # pylint: disable=too-many-instance-attri :vartype static_ip: str :ivar provisioning_state: Redis instance provisioning status. Known values are: "Creating", "Deleting", "Disabled", "Failed", "Linking", "Provisioning", "RecoveringScaleFailure", - "Scaling", "Succeeded", "Unlinking", "Unprovisioning", and "Updating". + "Scaling", "Succeeded", "Unlinking", "Unprovisioning", "Updating", and "ConfiguringAAD". :vartype provisioning_state: str or ~azure.mgmt.redis.models.ProvisioningState :ivar host_name: Redis host name. :vartype host_name: str @@ -2620,6 +2826,7 @@ class RedisResource(TrackedResource): # pylint: disable=too-many-instance-attri "shard_count": {"key": "properties.shardCount", "type": "int"}, "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "properties.updateChannel", "type": "str"}, "sku": {"key": "properties.sku", "type": "Sku"}, "subnet_id": {"key": "properties.subnetId", "type": "str"}, "static_ip": {"key": "properties.staticIP", "type": "str"}, @@ -2653,6 +2860,7 @@ def __init__( # pylint: disable=too-many-locals shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, subnet_id: Optional[str] = None, static_ip: Optional[str] = None, **kwargs: Any @@ -2694,6 +2902,11 @@ def __init__( # pylint: disable=too-many-locals private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. Required. :paramtype sku: ~azure.mgmt.redis.models.Sku :keyword subnet_id: The full resource ID of a subnet in a virtual network to deploy the Redis @@ -2716,6 +2929,7 @@ def __init__( # pylint: disable=too-many-locals self.shard_count = shard_count self.minimum_tls_version = minimum_tls_version self.public_network_access = public_network_access + self.update_channel = update_channel self.sku = sku self.subnet_id = subnet_id self.static_ip = static_ip @@ -2762,6 +2976,11 @@ class RedisUpdateParameters(_serialization.Model): # pylint: disable=too-many-i endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. :vartype sku: ~azure.mgmt.redis.models.Sku """ @@ -2781,6 +3000,7 @@ class RedisUpdateParameters(_serialization.Model): # pylint: disable=too-many-i "shard_count": {"key": "properties.shardCount", "type": "int"}, "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "properties.updateChannel", "type": "str"}, "sku": {"key": "properties.sku", "type": "Sku"}, } @@ -2798,6 +3018,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, sku: Optional["_models.Sku"] = None, **kwargs: Any ) -> None: @@ -2834,6 +3055,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. :paramtype sku: ~azure.mgmt.redis.models.Sku """ @@ -2849,10 +3075,11 @@ def __init__( self.shard_count = shard_count self.minimum_tls_version = minimum_tls_version self.public_network_access = public_network_access + self.update_channel = update_channel self.sku = sku -class RedisUpdateProperties(RedisCommonProperties): +class RedisUpdateProperties(RedisCommonProperties): # pylint: disable=too-many-instance-attributes """Patchable properties of the redis cache. :ivar redis_configuration: All Redis Settings. Few possible keys: @@ -2881,6 +3108,11 @@ class RedisUpdateProperties(RedisCommonProperties): endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :ivar update_channel: Optional: Specifies the update channel for the monthly Redis updates your + Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at + least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :vartype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :ivar sku: The SKU of the Redis cache to deploy. :vartype sku: ~azure.mgmt.redis.models.Sku """ @@ -2895,6 +3127,7 @@ class RedisUpdateProperties(RedisCommonProperties): "shard_count": {"key": "shardCount", "type": "int"}, "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "update_channel": {"key": "updateChannel", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, } @@ -2910,6 +3143,7 @@ def __init__( shard_count: Optional[int] = None, minimum_tls_version: Optional[Union[str, "_models.TlsVersion"]] = None, public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + update_channel: Optional[Union[str, "_models.UpdateChannel"]] = None, sku: Optional["_models.Sku"] = None, **kwargs: Any ) -> None: @@ -2942,6 +3176,11 @@ def __init__( private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.redis.models.PublicNetworkAccess + :keyword update_channel: Optional: Specifies the update channel for the monthly Redis updates + your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates + at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'. Known values are: + "Stable" and "Preview". + :paramtype update_channel: str or ~azure.mgmt.redis.models.UpdateChannel :keyword sku: The SKU of the Redis cache to deploy. :paramtype sku: ~azure.mgmt.redis.models.Sku """ @@ -2955,6 +3194,7 @@ def __init__( shard_count=shard_count, minimum_tls_version=minimum_tls_version, public_network_access=public_network_access, + update_channel=update_channel, **kwargs ) self.sku = sku diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_redis_management_client_enums.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_redis_management_client_enums.py index afd3f3c3fb3e..5aafc27fb0b6 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_redis_management_client_enums.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/models/_redis_management_client_enums.py @@ -10,6 +10,35 @@ from azure.core import CaseInsensitiveEnumMeta +class AccessPolicyAssignmentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of an access policy assignment set.""" + + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + + +class AccessPolicyProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of access policy.""" + + UPDATING = "Updating" + SUCCEEDED = "Succeeded" + DELETING = "Deleting" + DELETED = "Deleted" + CANCELED = "Canceled" + FAILED = "Failed" + + +class AccessPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Built-In or Custom access policy.""" + + CUSTOM = "Custom" + BUILT_IN = "BuiltIn" + + class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Day of the week when a cache can be patched.""" @@ -73,6 +102,7 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): UNLINKING = "Unlinking" UNPROVISIONING = "Unprovisioning" UPDATING = "Updating" + CONFIGURING_AAD = "ConfiguringAAD" class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -130,3 +160,13 @@ class TlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): ONE0 = "1.0" ONE1 = "1.1" ONE2 = "1.2" + + +class UpdateChannel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will + receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead + of 'Stable' channel caches. Default value is 'Stable'. + """ + + STABLE = "Stable" + PREVIEW = "Preview" diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/__init__.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/__init__.py index 8237f395ab5c..4d3740bcc656 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/__init__.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/__init__.py @@ -14,6 +14,8 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._async_operation_status_operations import AsyncOperationStatusOperations +from ._access_policy_operations import AccessPolicyOperations +from ._access_policy_assignment_operations import AccessPolicyAssignmentOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -28,6 +30,8 @@ "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", "AsyncOperationStatusOperations", + "AccessPolicyOperations", + "AccessPolicyAssignmentOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_assignment_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_assignment_operations.py new file mode 100644 index 000000000000..c2cefc2dc6c4 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_assignment_operations.py @@ -0,0 +1,752 @@ +# pylint: disable=too-many-lines +# 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 +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 +from .._vendor import _convert_request + +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, cache_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", "2023-08-01")) + 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/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", + access_policy_assignment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_delete_request( + resource_group_name: str, cache_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", + access_policy_assignment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_get_request( + resource_group_name: str, cache_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyAssignmentName": _SERIALIZER.url( + "access_policy_assignment_name", + access_policy_assignment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_request(resource_group_name: str, cache_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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.redis.RedisManagementClient`'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, + cache_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO], + **kwargs: Any + ) -> _models.RedisCacheAccessPolicyAssignment: + error_map = { + 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[_models.RedisCacheAccessPolicyAssignment] = 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, "RedisCacheAccessPolicyAssignment") + + request = build_create_update_request( + resource_group_name=resource_group_name, + cache_name=cache_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, + template_url=self._create_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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("RedisCacheAccessPolicyAssignment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @overload + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: _models.RedisCacheAccessPolicyAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicyAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicyAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_assignment_name: str, + parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO], + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicyAssignment]: + """Adds the access policy assignment to the specified users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :param parameters: Parameters supplied to the Create Update Access Policy Assignment operation. + Is either a RedisCacheAccessPolicyAssignment type or a IO type. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicyAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :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.RedisCacheAccessPolicyAssignment] = 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, + cache_name=cache_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 + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> None: + error_map = { + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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, 202, 204]: + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the access policy assignment from a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either 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( # type: ignore + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any + ) -> _models.RedisCacheAccessPolicyAssignment: + """Gets the list of assignments for an access policy of a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_assignment_name: The name of the access policy assignment. Required. + :type access_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RedisCacheAccessPolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.RedisCacheAccessPolicyAssignment] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_assignment_name=access_policy_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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("RedisCacheAccessPolicyAssignment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments/{accessPolicyAssignmentName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> Iterable["_models.RedisCacheAccessPolicyAssignment"]: + """Gets the list of access policy assignments associated with this redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RedisCacheAccessPolicyAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redis.models.RedisCacheAccessPolicyAssignment] + :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.RedisCacheAccessPolicyAssignmentList] = kwargs.pop("cls", None) + + error_map = { + 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, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyAssignmentList", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicyAssignments" + } diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_operations.py new file mode 100644 index 000000000000..1eb7e03f307b --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_access_policy_operations.py @@ -0,0 +1,752 @@ +# pylint: disable=too-many-lines +# 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 +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 +from .._vendor import _convert_request + +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, cache_name: str, access_policy_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", "2023-08-01")) + 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/redis/{cacheName}/accessPolicies/{accessPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyName": _SERIALIZER.url( + "access_policy_name", + access_policy_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_delete_request( + resource_group_name: str, cache_name: str, access_policy_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyName": _SERIALIZER.url( + "access_policy_name", + access_policy_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_get_request( + resource_group_name: str, cache_name: str, access_policy_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "accessPolicyName": _SERIALIZER.url( + "access_policy_name", + access_policy_name, + "str", + max_length=63, + min_length=3, + pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_list_request(resource_group_name: str, cache_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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 AccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redis.RedisManagementClient`'s + :attr:`access_policy` 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, + cache_name: str, + access_policy_name: str, + parameters: Union[_models.RedisCacheAccessPolicy, IO], + **kwargs: Any + ) -> _models.RedisCacheAccessPolicy: + error_map = { + 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[_models.RedisCacheAccessPolicy] = 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, "RedisCacheAccessPolicy") + + request = build_create_update_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 201]: + 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("RedisCacheAccessPolicy", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("RedisCacheAccessPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @overload + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: _models.RedisCacheAccessPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update( + self, + resource_group_name: str, + cache_name: str, + access_policy_name: str, + parameters: Union[_models.RedisCacheAccessPolicy, IO], + **kwargs: Any + ) -> LROPoller[_models.RedisCacheAccessPolicy]: + """Adds an access policy to the redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :param parameters: Parameters supplied to the Create Update Access Policy operation. Is either + a RedisCacheAccessPolicy type or a IO type. Required. + :type parameters: ~azure.mgmt.redis.models.RedisCacheAccessPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RedisCacheAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :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.RedisCacheAccessPolicy] = 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, + cache_name=cache_name, + access_policy_name=access_policy_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicy", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> None: + error_map = { + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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, 202, 204]: + 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")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the access policy from a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either 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( # type: ignore + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, cache_name: str, access_policy_name: str, **kwargs: Any + ) -> _models.RedisCacheAccessPolicy: + """Gets the detailed information about an access policy of a redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :param access_policy_name: The name of the access policy that is being added to the Redis + cache. Required. + :type access_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RedisCacheAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.redis.models.RedisCacheAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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.RedisCacheAccessPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + access_policy_name=access_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _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("RedisCacheAccessPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies/{accessPolicyName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> Iterable["_models.RedisCacheAccessPolicy"]: + """Gets the list of access policies associated with this redis cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RedisCacheAccessPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redis.models.RedisCacheAccessPolicy] + :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.RedisCacheAccessPolicyList] = kwargs.pop("cls", None) + + error_map = { + 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, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RedisCacheAccessPolicyList", 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) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/accessPolicies" + } diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_async_operation_status_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_async_operation_status_operations.py index 3321a49b748f..b4b4eeb84c5d 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_async_operation_status_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_async_operation_status_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +38,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,10 +49,10 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** path_format_arguments = { "location": _SERIALIZER.url("location", location, "str"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_firewall_rules_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_firewall_rules_operations.py index d8838cb745be..b22a986b5b0f 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_firewall_rules_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_firewall_rules_operations.py @@ -28,7 +28,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +41,7 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,12 +50,16 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "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 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,7 +76,7 @@ def build_create_or_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -82,13 +86,17 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +115,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,13 +124,17 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +151,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,13 +160,17 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,7 +204,8 @@ def __init__(self, *args, **kwargs): def list(self, resource_group_name: str, cache_name: str, **kwargs: Any) -> Iterable["_models.RedisFirewallRule"]: """Gets all firewall rules in the specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -286,7 +303,8 @@ def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -317,7 +335,8 @@ def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -346,7 +365,8 @@ def create_or_update( ) -> _models.RedisFirewallRule: """Create or update a redis cache firewall rule. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -435,7 +455,8 @@ def get( ) -> _models.RedisFirewallRule: """Gets a single firewall rule in a specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -502,7 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a single firewall rule in a specified redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_linked_server_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_linked_server_operations.py index c511ff5c53ae..e9d885b50ae7 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_linked_server_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_linked_server_operations.py @@ -30,7 +30,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +45,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -55,13 +55,15 @@ def build_create_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "linkedServerName": _SERIALIZER.url("linked_server_name", linked_server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +82,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,13 +91,15 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "linkedServerName": _SERIALIZER.url("linked_server_name", linked_server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,7 +116,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,13 +125,15 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "linkedServerName": _SERIALIZER.url("linked_server_name", linked_server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,7 +148,7 @@ def build_list_request(resource_group_name: str, name: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -151,12 +157,14 @@ def build_list_request(resource_group_name: str, name: str, subscription_id: str "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -273,7 +281,8 @@ def begin_create( ) -> LROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -312,7 +321,8 @@ def begin_create( ) -> LROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -349,7 +359,8 @@ def begin_create( ) -> LROPoller[_models.RedisLinkedServerWithProperties]: """Adds a linked server to the Redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -466,8 +477,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, response_headers) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/linkedServers/{linkedServerName}" @@ -479,7 +494,8 @@ def begin_delete( ) -> LROPoller[None]: """Deletes the linked server from a redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -548,7 +564,8 @@ def get( ) -> _models.RedisLinkedServerWithProperties: """Gets the detailed information about a linked server of a redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -615,7 +632,8 @@ def list( ) -> Iterable["_models.RedisLinkedServerWithProperties"]: """Gets the list of linked servers associated with this redis cache (requires Premium SKU). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_operations.py index df54efb3bb07..c395181c1f57 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_operations.py @@ -40,7 +40,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_patch_schedules_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_patch_schedules_operations.py index b54c13bbd69e..b0f910fa482a 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_patch_schedules_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_patch_schedules_operations.py @@ -28,7 +28,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +43,7 @@ def build_list_by_redis_resource_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,12 +52,16 @@ def build_list_by_redis_resource_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/patchSchedules", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "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 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,7 +78,7 @@ def build_create_or_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -84,13 +88,15 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "default": _SERIALIZER.url("default", default, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +115,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,13 +124,15 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "default": _SERIALIZER.url("default", default, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +149,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,13 +158,15 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/patchSchedules/{default}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), "default": _SERIALIZER.url("default", default, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +202,8 @@ def list_by_redis_resource( ) -> Iterable["_models.RedisPatchSchedule"]: """Gets all patch schedules in the specified redis cache (there is only one). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -290,7 +301,8 @@ def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -321,7 +333,8 @@ def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -350,7 +363,8 @@ def create_or_update( ) -> _models.RedisPatchSchedule: """Create or replace the patching schedule for Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -440,7 +454,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes the patching schedule of a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str @@ -504,7 +519,8 @@ def get( ) -> _models.RedisPatchSchedule: """Gets the patching schedule of a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the redis cache. Required. :type name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_endpoint_connections_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_endpoint_connections_operations.py index 02d1c97c3592..8ce6f7ff03e3 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_endpoint_connections_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_endpoint_connections_operations.py @@ -30,7 +30,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +43,7 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,12 +52,16 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +82,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,15 +91,19 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +124,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -126,15 +134,19 @@ def build_put_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[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" ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,7 +169,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,15 +178,19 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[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" ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +226,8 @@ def list( ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -302,7 +319,8 @@ def get( ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -451,7 +469,8 @@ def begin_put( ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -490,7 +509,8 @@ def begin_put( ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -527,7 +547,8 @@ def begin_put( ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str @@ -608,7 +629,8 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes the specified private endpoint connection associated with the redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_link_resources_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_link_resources_operations.py index e3d2798250c5..ef01040d54d9 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_link_resources_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_link_resources_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +42,7 @@ def build_list_by_redis_cache_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,12 +51,16 @@ def build_list_by_redis_cache_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/privateLinkResources", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "cacheName": _SERIALIZER.url("cache_name", cache_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +96,8 @@ def list_by_redis_cache( ) -> Iterable["_models.PrivateLinkResource"]: """Gets the private link resources that need to be created for a redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cache_name: The name of the Redis cache. Required. :type cache_name: str diff --git a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_redis_operations.py b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_redis_operations.py index d770432c4276..deb2e89410b7 100644 --- a/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_redis_operations.py +++ b/sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_redis_operations.py @@ -30,7 +30,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,17 +43,17 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) 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}/providers/Microsoft.Cache/CheckNameAvailability") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,7 +72,7 @@ def build_list_upgrade_notifications_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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,12 +81,14 @@ def build_list_upgrade_notifications_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/listUpgradeNotifications", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +104,7 @@ def build_create_request(resource_group_name: str, name: str, subscription_id: s _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -112,12 +114,14 @@ def build_create_request(resource_group_name: str, name: str, subscription_id: s "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +138,7 @@ def build_update_request(resource_group_name: str, name: str, subscription_id: s _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,12 +148,14 @@ def build_update_request(resource_group_name: str, name: str, subscription_id: s "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,7 +172,7 @@ def build_delete_request(resource_group_name: str, name: str, subscription_id: s _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -175,12 +181,14 @@ def build_delete_request(resource_group_name: str, name: str, subscription_id: s "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -195,7 +203,7 @@ def build_get_request(resource_group_name: str, name: 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -204,12 +212,14 @@ def build_get_request(resource_group_name: str, name: str, subscription_id: str, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -224,7 +234,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,11 +243,13 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -252,16 +264,16 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redis") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,7 +288,7 @@ def build_list_keys_request(resource_group_name: str, name: str, subscription_id _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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -285,12 +297,14 @@ def build_list_keys_request(resource_group_name: str, name: str, subscription_id "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/listKeys", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,7 +321,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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -317,12 +331,14 @@ def build_regenerate_key_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/regenerateKey", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -339,7 +355,7 @@ def build_force_reboot_request(resource_group_name: str, 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -349,12 +365,14 @@ def build_force_reboot_request(resource_group_name: str, name: str, subscription "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/forceReboot", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -371,7 +389,7 @@ def build_import_data_request(resource_group_name: str, 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -381,12 +399,14 @@ def build_import_data_request(resource_group_name: str, name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/import", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -403,7 +423,7 @@ def build_export_data_request(resource_group_name: str, 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", "2023-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -413,12 +433,14 @@ def build_export_data_request(resource_group_name: str, name: str, subscription_ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/export", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,6 +453,41 @@ def build_export_data_request(resource_group_name: str, name: str, subscription_ return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_flush_cache_request( + resource_group_name: str, cache_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", "2023-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/flush", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cacheName": _SERIALIZER.url( + "cache_name", cache_name, "str", pattern=r"^([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]|[a-zA-Z0-9])$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class RedisOperations: """ .. warning:: @@ -569,7 +626,8 @@ def list_upgrade_notifications( ) -> Iterable["_models.UpgradeNotification"]: """Gets any upgrade notifications for a Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -737,7 +795,8 @@ def begin_create( ) -> LROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -772,7 +831,8 @@ def begin_create( ) -> LROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -801,7 +861,8 @@ def begin_create( ) -> LROPoller[_models.RedisResource]: """Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -952,7 +1013,8 @@ def begin_update( ) -> LROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -987,7 +1049,8 @@ def begin_update( ) -> LROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1016,7 +1079,8 @@ def begin_update( ) -> LROPoller[_models.RedisResource]: """Update an existing Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1139,7 +1203,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1202,7 +1267,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.RedisResource: """Gets a Redis cache (resource description). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1264,7 +1330,8 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.Red def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RedisResource"]: """Lists all Redis caches in a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RedisResource or the result of cls(response) @@ -1432,7 +1499,8 @@ def list_keys(self, resource_group_name: str, name: str, **kwargs: Any) -> _mode """Retrieve a Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1503,7 +1571,8 @@ def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1531,7 +1600,8 @@ def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1557,7 +1627,8 @@ def regenerate_key( """Regenerate Redis cache's access keys. This operation requires write permission to the cache resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1646,7 +1717,8 @@ def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1674,7 +1746,8 @@ def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1696,7 +1769,8 @@ def force_reboot( """Reboot specified Redis node(s). This operation requires write permission to the cache resource. There can be potential data loss. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1844,7 +1918,8 @@ def begin_import_data( ) -> LROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1878,7 +1953,8 @@ def begin_import_data( ) -> LROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -1906,7 +1982,8 @@ def begin_import_data( ) -> LROPoller[None]: """Import data into Redis cache. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -2046,7 +2123,8 @@ def begin_export_data( ) -> LROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -2080,7 +2158,8 @@ def begin_export_data( ) -> LROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -2108,7 +2187,8 @@ def begin_export_data( ) -> LROPoller[None]: """Export data from the redis cache to blobs in a container. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param name: The name of the Redis cache. Required. :type name: str @@ -2175,3 +2255,147 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_export_data.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}/export" } + + def _flush_cache_initial( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + error_map = { + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + request = build_flush_cache_request( + resource_group_name=resource_group_name, + cache_name=cache_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._flush_cache_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + 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, 202]: + 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 + response_headers = {} + if response.status_code == 200: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + 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") + ) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _flush_cache_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/flush" + } + + @distributed_trace + def begin_flush_cache( + self, resource_group_name: str, cache_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """Deletes all of the keys in a cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cache_name: The name of the Redis cache. Required. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redis.models.OperationStatusResult] + :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.OperationStatusResult] = 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._flush_cache_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_flush_cache.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/flush" + } diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_create_update.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_create_update.py new file mode 100644 index 000000000000..218b7c62e4e1 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_create_update.py @@ -0,0 +1,49 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy_assignment.begin_create_update( + resource_group_name="rg1", + cache_name="cache1", + access_policy_assignment_name="accessPolicyAssignmentName1", + parameters={ + "properties": { + "accessPolicyName": "accessPolicy1", + "objectId": "6497c918-11ad-41e7-1b0f-7c518a87d0b0", + "objectIdAlias": "TestAADAppRedis", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyAssignmentCreateUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_delete.py new file mode 100644 index 000000000000..dd23d2ab3da1 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_delete.py @@ -0,0 +1,41 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + client.access_policy_assignment.begin_delete( + resource_group_name="rg1", + cache_name="cache1", + access_policy_assignment_name="accessPolicyAssignmentName1", + ).result() + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyAssignmentDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_get.py new file mode 100644 index 000000000000..c9a09adda80e --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_get.py @@ -0,0 +1,42 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy_assignment.get( + resource_group_name="rg1", + cache_name="cache1", + access_policy_assignment_name="accessPolicyAssignmentName1", + ) + print(response) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyAssignmentGet.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_list.py new file mode 100644 index 000000000000..796744f55a0e --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_assignment_list.py @@ -0,0 +1,42 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_access_policy_assignment_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy_assignment.list( + resource_group_name="rg1", + cache_name="cache1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyAssignmentList.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_create_update.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_create_update.py new file mode 100644 index 000000000000..d0a82071baea --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_create_update.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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_access_policy_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy.begin_create_update( + resource_group_name="rg1", + cache_name="cache1", + access_policy_name="accessPolicy1", + parameters={"properties": {"permissions": "+get +hget"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyCreateUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_delete.py new file mode 100644 index 000000000000..927a2d54bc10 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_delete.py @@ -0,0 +1,41 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_access_policy_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + client.access_policy.begin_delete( + resource_group_name="rg1", + cache_name="cache1", + access_policy_name="accessPolicy1", + ).result() + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_get.py new file mode 100644 index 000000000000..7dde43122105 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_get.py @@ -0,0 +1,42 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_access_policy_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy.get( + resource_group_name="rg1", + cache_name="cache1", + access_policy_name="accessPolicy1", + ) + print(response) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyGet.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_list.py new file mode 100644 index 000000000000..aec8f2f03fa6 --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_access_policy_list.py @@ -0,0 +1,42 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_access_policy_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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.access_policy.list( + resource_group_name="rg1", + cache_name="cache1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAccessPolicyList.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_async_operation_status.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_async_operation_status.py index 1c3f5cd6993f..3d1a33446740 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_async_operation_status.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_async_operation_status.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheAsyncOperationStatus.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheAsyncOperationStatus.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_check_name_availability.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_check_name_availability.py index 7f3f233dffa9..d4d264280dc6 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_check_name_availability.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_check_name_availability.py @@ -34,6 +34,6 @@ def main(): ) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheCheckNameAvailability.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create.py index 4e6dd79a440e..d8925c0b6a7a 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create.py @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheCreate.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheCreate.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_default_version.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_default_version.py index 8ea34d8bc31b..fe95c8995465 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_default_version.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_default_version.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheCreateDefaultVersion.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheCreateDefaultVersion.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_latest_version.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_latest_version.py index 9d2742263e25..d64403a14dbc 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_latest_version.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_create_latest_version.py @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheCreateLatestVersion.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheCreateLatestVersion.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete.py index 0c364a3f231c..a61a205b2683 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheDelete.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheDelete.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete_private_endpoint_connection.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete_private_endpoint_connection.py index 9333c9747d3c..1a7635473e17 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete_private_endpoint_connection.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_delete_private_endpoint_connection.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheDeletePrivateEndpointConnection.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheDeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_export.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_export.py index a3156bec9026..f69be520fa88 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_export.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_export.py @@ -41,6 +41,6 @@ def main(): ).result() -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheExport.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheExport.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_create.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_create.py index d43334714a7f..bc579277beb5 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_create.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheFirewallRuleCreate.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheFirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_delete.py index ebbb1dc4e02d..8c2e2983b042 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_delete.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheFirewallRuleDelete.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheFirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_get.py index 15a97b420b79..241ea6a9289e 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_get.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rule_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheFirewallRuleGet.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheFirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rules_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rules_list.py index 46acd5fd2ecf..7deffb162b35 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rules_list.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_firewall_rules_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheFirewallRulesList.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheFirewallRulesList.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_flush.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_flush.py new file mode 100644 index 000000000000..cc6daf28e43f --- /dev/null +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_flush.py @@ -0,0 +1,41 @@ +# 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.redis import RedisManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-redis +# USAGE + python redis_cache_flush.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 = RedisManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subcription-id", + ) + + response = client.redis.begin_flush_cache( + resource_group_name="resource-group-name", + cache_name="cache-name", + ).result() + print(response) + + +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheFlush.json +if __name__ == "__main__": + main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_force_reboot.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_force_reboot.py index 2c78ca4949e9..94d01845fed9 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_force_reboot.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_force_reboot.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheForceReboot.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheForceReboot.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get.py index 321c0bdabbab..5d30751bd966 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheGet.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheGet.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get_private_endpoint_connection.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get_private_endpoint_connection.py index e17aedd0dc1f..d957874d3cc4 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get_private_endpoint_connection.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_get_private_endpoint_connection.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheGetPrivateEndpointConnection.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheGetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_import.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_import.py index a3c129caf7e7..3f70d3e50375 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_import.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_import.py @@ -40,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheImport.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheImport.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_create.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_create.py index 54736ab998ad..e162afef28ee 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_create.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_create.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheLinkedServer_Create.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheLinkedServer_Create.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_delete.py index 53f3ceb729cd..a820b10b3bd4 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_delete.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheLinkedServer_Delete.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheLinkedServer_Delete.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_get.py index b448a35a6f90..9349f7b8fd4c 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_get.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheLinkedServer_Get.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheLinkedServer_Get.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_list.py index eabe3aea9ea0..815f6c9c12ca 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_list.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_linked_server_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheLinkedServer_List.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheLinkedServer_List.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list.py index 0030ac930054..87de5a2d8c49 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheList.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheList.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_by_resource_group.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_by_resource_group.py index c73587eec3f5..d2b160a5c3c3 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_by_resource_group.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheListByResourceGroup.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_keys.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_keys.py index e5028c36a68b..423179ef626e 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_keys.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_keys.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheListKeys.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheListKeys.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_endpoint_connections.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_endpoint_connections.py index 5891c86c3aae..f347ec976ac5 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_endpoint_connections.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_endpoint_connections.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheListPrivateEndpointConnections.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheListPrivateEndpointConnections.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_link_resources.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_link_resources.py index 4966d9d8c732..530e1411b85e 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_link_resources.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_private_link_resources.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheListPrivateLinkResources.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheListPrivateLinkResources.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_upgrade_notifications.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_upgrade_notifications.py index 14cea93aa6ea..df75f6499f48 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_upgrade_notifications.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_list_upgrade_notifications.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheListUpgradeNotifications.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheListUpgradeNotifications.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_operations.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_operations.py index d3df255b2f74..a3dbb051830c 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_operations.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_operations.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheOperations.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheOperations.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_create_or_update.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_create_or_update.py index a102ea618e06..6b1561a23004 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_create_or_update.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_create_or_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCachePatchSchedulesCreateOrUpdate.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCachePatchSchedulesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_delete.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_delete.py index 7b1676ab6741..0456374e39ee 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_delete.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCachePatchSchedulesDelete.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCachePatchSchedulesDelete.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_get.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_get.py index 85267ac7761f..733da0c1d244 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_get.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCachePatchSchedulesGet.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCachePatchSchedulesGet.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_list.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_list.py index af8f3abc4275..ae98677ff55d 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_list.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_patch_schedules_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCachePatchSchedulesList.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCachePatchSchedulesList.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_put_private_endpoint_connection.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_put_private_endpoint_connection.py index 4bf688f31a01..a569a5fa7831 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_put_private_endpoint_connection.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_put_private_endpoint_connection.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCachePutPrivateEndpointConnection.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCachePutPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_regenerate_key.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_regenerate_key.py index ff420dfcb41f..6ab6d8e0d89f 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_regenerate_key.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_regenerate_key.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheRegenerateKey.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_update.py b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_update.py index 041362a2669d..2e0497b0a8ee 100644 --- a/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_update.py +++ b/sdk/redis/azure-mgmt-redis/generated_samples/redis_cache_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-04-01/examples/RedisCacheUpdate.json +# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2023-08-01/examples/RedisCacheUpdate.json if __name__ == "__main__": main()