Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR azure-mgmt-redis] Add ZonalAllocationPolicy property to the Redis Cache request, response - new stable API version: 2024-11-01 #9067

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdk/redis/azure-mgmt-redis/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "3aef2f96202eec656fca4abc4df0fbfe10b89ac0",
"commit": "b2cbd5328106a020f1aca87eea78d9308763338a",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.10.2",
"use": [
"@autorest/python@6.13.19",
"@autorest/python@6.19.0",
"@autorest/[email protected]"
],
"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 --tag=package-2024-03 --use=@autorest/python@6.13.19 --use=@autorest/[email protected] --version=3.10.2 --version-tolerant=False",
"autorest_command": "autorest specification/redis/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/[email protected] --version=3.10.2 --version-tolerant=False",
"readme": "specification/redis/resource-manager/readme.md"
}
4 changes: 2 additions & 2 deletions sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class RedisManagementClientConfiguration: # pylint: disable=too-many-instance-a
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-11-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:
api_version: str = kwargs.pop("api_version", "2024-03-01")
api_version: str = kwargs.pop("api_version", "2024-11-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from copy import deepcopy
from typing import Any, TYPE_CHECKING
from typing_extensions import Self

from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse
Expand Down Expand Up @@ -65,7 +66,7 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-11-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
Expand Down Expand Up @@ -150,7 +151,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
def close(self) -> None:
self._client.close()

def __enter__(self) -> "RedisManagementClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

Expand Down
2 changes: 2 additions & 0 deletions sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def _json_attemp(data):
# context otherwise.
_LOGGER.critical("Wasn't XML not JSON, failing")
raise DeserializationError("XML is invalid") from err
elif content_type.startswith("text/"):
return data_as_str
raise DeserializationError("Cannot deserialize content-type: {}".format(content_type))

@classmethod
Expand Down
16 changes: 0 additions & 16 deletions sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "14.4.0"
VERSION = "12.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class RedisManagementClientConfiguration: # pylint: disable=too-many-instance-a
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-11-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:
api_version: str = kwargs.pop("api_version", "2024-03-01")
api_version: str = kwargs.pop("api_version", "2024-11-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from typing_extensions import Self

from azure.core.pipeline import policies
from azure.core.rest import AsyncHttpResponse, HttpRequest
Expand Down Expand Up @@ -66,7 +67,7 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-11-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
Expand Down Expand Up @@ -153,7 +154,7 @@ def _send_request(
async def close(self) -> None:
await self._client.close()

async def __aenter__(self) -> "RedisManagementClient":
async def __aenter__(self) -> Self:
await self._client.__aenter__()
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# --------------------------------------------------------------------------
from io import IOBase
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload
from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload
import urllib.parse

from azure.core.async_paging import AsyncItemPaged, AsyncList
Expand All @@ -18,20 +18,20 @@
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
StreamClosedError,
StreamConsumedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
from azure.core.rest import HttpRequest
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.utils import case_insensitive_dict
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,
Expand Down Expand Up @@ -73,7 +73,7 @@ async def _create_update_initial(
access_policy_assignment_name: str,
parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO[bytes]],
**kwargs: Any
) -> _models.RedisCacheAccessPolicyAssignment:
) -> AsyncIterator[bytes]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
Expand All @@ -87,7 +87,7 @@ async def _create_update_initial(

api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.RedisCacheAccessPolicyAssignment] = kwargs.pop("cls", None)
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_json = None
Expand All @@ -109,26 +109,26 @@ async def _create_update_initial(
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)

_stream = False
_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200, 201]:
try:
await response.read() # Load the body in memory and close the socket
except (StreamConsumedError, StreamClosedError):
pass
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

if response.status_code == 200:
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)

if response.status_code == 201:
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -250,10 +250,11 @@ async def begin_create_update(
params=_params,
**kwargs
)
await raw_result.http_response.read() # type: ignore
kwargs.pop("error_map", None)

def get_long_running_output(pipeline_response):
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response.http_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized
Expand All @@ -275,9 +276,9 @@ def get_long_running_output(pipeline_response):
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)

async def _delete_initial( # pylint: disable=inconsistent-return-statements
async def _delete_initial(
self, resource_group_name: str, cache_name: str, access_policy_assignment_name: str, **kwargs: Any
) -> None:
) -> AsyncIterator[bytes]:
error_map: MutableMapping[int, Type[HttpResponseError]] = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
Expand All @@ -290,7 +291,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[None] = kwargs.pop("cls", None)
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)

_request = build_delete_request(
resource_group_name=resource_group_name,
Expand All @@ -301,17 +302,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)

_stream = False
_decompress = kwargs.pop("decompress", True)
_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200, 202, 204]:
try:
await response.read() # Load the body in memory and close the socket
except (StreamConsumedError, StreamClosedError):
pass
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand All @@ -320,8 +325,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))

deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

if cls:
return cls(pipeline_response, None, response_headers) # type: ignore
return cls(pipeline_response, deserialized, response_headers) # type: ignore

return deserialized # type: ignore

@distributed_trace_async
async def begin_delete(
Expand Down Expand Up @@ -349,7 +358,7 @@ async def begin_delete(
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
raw_result = await self._delete_initial(
resource_group_name=resource_group_name,
cache_name=cache_name,
access_policy_assignment_name=access_policy_assignment_name,
Expand All @@ -359,6 +368,7 @@ async def begin_delete(
params=_params,
**kwargs
)
await raw_result.http_response.read() # type: ignore
kwargs.pop("error_map", None)

def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
Expand Down Expand Up @@ -422,7 +432,6 @@ async def get(
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)

_stream = False
Expand All @@ -437,7 +446,7 @@ async def get(
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response.http_response)

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down Expand Up @@ -486,7 +495,6 @@ def prepare_request(next_link=None):
headers=_headers,
params=_params,
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)

else:
Expand All @@ -502,7 +510,6 @@ def prepare_request(next_link=None):
_request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
_request = _convert_request(_request)
_request.url = self._client.format_url(_request.url)
_request.method = "GET"
return _request
Expand Down
Loading