Skip to content

Commit d56614b

Browse files
author
SDKAuto
committed
CodeGen from PR 30795 in Azure/azure-rest-api-specs
Merge fe0ff49118a2993b7e1bc7361b33f09cd7dbe7fc into 1e028c56972480c9c80187dbdbd6e73c931ff8ac
1 parent ae22841 commit d56614b

File tree

99 files changed

+2608
-591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2608
-591
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "3aef2f96202eec656fca4abc4df0fbfe10b89ac0",
2+
"commit": "762c6056e4819a89f7e337c7b434d7996d531236",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.13.19",
6+
"@autorest/python@6.19.0",
77
"@autorest/[email protected]"
88
],
9-
"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",
9+
"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",
1010
"readme": "specification/redis/resource-manager/readme.md"
1111
}

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class RedisManagementClientConfiguration: # pylint: disable=too-many-instance-a
2828
:type credential: ~azure.core.credentials.TokenCredential
2929
:param subscription_id: The ID of the target subscription. Required.
3030
:type subscription_id: str
31-
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2024-10-01". Note that overriding this
3232
default value may result in unsupported behavior.
3333
:paramtype api_version: str
3434
"""
3535

3636
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
37-
api_version: str = kwargs.pop("api_version", "2024-03-01")
37+
api_version: str = kwargs.pop("api_version", "2024-10-01")
3838

3939
if credential is None:
4040
raise ValueError("Parameter 'credential' must not be None.")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_redis_management_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
1112

1213
from azure.core.pipeline import policies
1314
from azure.core.rest import HttpRequest, HttpResponse
@@ -65,7 +66,7 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo
6566
:type subscription_id: str
6667
:param base_url: Service URL. Default value is "https://management.azure.com".
6768
:type base_url: str
68-
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
69+
:keyword api_version: Api Version. Default value is "2024-10-01". Note that overriding this
6970
default value may result in unsupported behavior.
7071
:paramtype api_version: str
7172
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -150,7 +151,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
150151
def close(self) -> None:
151152
self._client.close()
152153

153-
def __enter__(self) -> "RedisManagementClient":
154+
def __enter__(self) -> Self:
154155
self._client.__enter__()
155156
return self
156157

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def _json_attemp(data):
144144
# context otherwise.
145145
_LOGGER.critical("Wasn't XML not JSON, failing")
146146
raise DeserializationError("XML is invalid") from err
147+
elif content_type.startswith("text/"):
148+
return data_as_str
147149
raise DeserializationError("Cannot deserialize content-type: {}".format(content_type))
148150

149151
@classmethod

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "14.4.0"
9+
VERSION = "12.0.0b1"

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class RedisManagementClientConfiguration: # pylint: disable=too-many-instance-a
2828
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
2929
:param subscription_id: The ID of the target subscription. Required.
3030
:type subscription_id: str
31-
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2024-10-01". Note that overriding this
3232
default value may result in unsupported behavior.
3333
:paramtype api_version: str
3434
"""
3535

3636
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
37-
api_version: str = kwargs.pop("api_version", "2024-03-01")
37+
api_version: str = kwargs.pop("api_version", "2024-10-01")
3838

3939
if credential is None:
4040
raise ValueError("Parameter 'credential' must not be None.")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/_redis_management_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any, Awaitable, TYPE_CHECKING
11+
from typing_extensions import Self
1112

1213
from azure.core.pipeline import policies
1314
from azure.core.rest import AsyncHttpResponse, HttpRequest
@@ -66,7 +67,7 @@ class RedisManagementClient: # pylint: disable=client-accepts-api-version-keywo
6667
:type subscription_id: str
6768
:param base_url: Service URL. Default value is "https://management.azure.com".
6869
:type base_url: str
69-
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
70+
:keyword api_version: Api Version. Default value is "2024-10-01". Note that overriding this
7071
default value may result in unsupported behavior.
7172
:paramtype api_version: str
7273
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -153,7 +154,7 @@ def _send_request(
153154
async def close(self) -> None:
154155
await self._client.close()
155156

156-
async def __aenter__(self) -> "RedisManagementClient":
157+
async def __aenter__(self) -> Self:
157158
await self._client.__aenter__()
158159
return self
159160

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/aio/operations/_access_policy_assignment_operations.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# --------------------------------------------------------------------------
99
from io import IOBase
1010
import sys
11-
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload
11+
from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload
1212
import urllib.parse
1313

1414
from azure.core.async_paging import AsyncItemPaged, AsyncList
@@ -18,20 +18,20 @@
1818
ResourceExistsError,
1919
ResourceNotFoundError,
2020
ResourceNotModifiedError,
21+
StreamClosedError,
22+
StreamConsumedError,
2123
map_error,
2224
)
2325
from azure.core.pipeline import PipelineResponse
24-
from azure.core.pipeline.transport import AsyncHttpResponse
2526
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
26-
from azure.core.rest import HttpRequest
27+
from azure.core.rest import AsyncHttpResponse, HttpRequest
2728
from azure.core.tracing.decorator import distributed_trace
2829
from azure.core.tracing.decorator_async import distributed_trace_async
2930
from azure.core.utils import case_insensitive_dict
3031
from azure.mgmt.core.exceptions import ARMErrorFormat
3132
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
3233

3334
from ... import models as _models
34-
from ..._vendor import _convert_request
3535
from ...operations._access_policy_assignment_operations import (
3636
build_create_update_request,
3737
build_delete_request,
@@ -73,7 +73,7 @@ async def _create_update_initial(
7373
access_policy_assignment_name: str,
7474
parameters: Union[_models.RedisCacheAccessPolicyAssignment, IO[bytes]],
7575
**kwargs: Any
76-
) -> _models.RedisCacheAccessPolicyAssignment:
76+
) -> AsyncIterator[bytes]:
7777
error_map: MutableMapping[int, Type[HttpResponseError]] = {
7878
401: ClientAuthenticationError,
7979
404: ResourceNotFoundError,
@@ -87,7 +87,7 @@ async def _create_update_initial(
8787

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

9292
content_type = content_type or "application/json"
9393
_json = None
@@ -109,26 +109,26 @@ async def _create_update_initial(
109109
headers=_headers,
110110
params=_params,
111111
)
112-
_request = _convert_request(_request)
113112
_request.url = self._client.format_url(_request.url)
114113

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

120120
response = pipeline_response.http_response
121121

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

127-
if response.status_code == 200:
128-
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
129-
130-
if response.status_code == 201:
131-
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
131+
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)
132132

133133
if cls:
134134
return cls(pipeline_response, deserialized, {}) # type: ignore
@@ -250,10 +250,11 @@ async def begin_create_update(
250250
params=_params,
251251
**kwargs
252252
)
253+
await raw_result.http_response.read() # type: ignore
253254
kwargs.pop("error_map", None)
254255

255256
def get_long_running_output(pipeline_response):
256-
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
257+
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response.http_response)
257258
if cls:
258259
return cls(pipeline_response, deserialized, {}) # type: ignore
259260
return deserialized
@@ -275,9 +276,9 @@ def get_long_running_output(pipeline_response):
275276
self._client, raw_result, get_long_running_output, polling_method # type: ignore
276277
)
277278

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

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

295296
_request = build_delete_request(
296297
resource_group_name=resource_group_name,
@@ -301,17 +302,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
301302
headers=_headers,
302303
params=_params,
303304
)
304-
_request = _convert_request(_request)
305305
_request.url = self._client.format_url(_request.url)
306306

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

312313
response = pipeline_response.http_response
313314

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

328+
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)
329+
323330
if cls:
324-
return cls(pipeline_response, None, response_headers) # type: ignore
331+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
332+
333+
return deserialized # type: ignore
325334

326335
@distributed_trace_async
327336
async def begin_delete(
@@ -349,7 +358,7 @@ async def begin_delete(
349358
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
350359
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
351360
if cont_token is None:
352-
raw_result = await self._delete_initial( # type: ignore
361+
raw_result = await self._delete_initial(
353362
resource_group_name=resource_group_name,
354363
cache_name=cache_name,
355364
access_policy_assignment_name=access_policy_assignment_name,
@@ -359,6 +368,7 @@ async def begin_delete(
359368
params=_params,
360369
**kwargs
361370
)
371+
await raw_result.http_response.read() # type: ignore
362372
kwargs.pop("error_map", None)
363373

364374
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
@@ -422,7 +432,6 @@ async def get(
422432
headers=_headers,
423433
params=_params,
424434
)
425-
_request = _convert_request(_request)
426435
_request.url = self._client.format_url(_request.url)
427436

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

440-
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response)
449+
deserialized = self._deserialize("RedisCacheAccessPolicyAssignment", pipeline_response.http_response)
441450

442451
if cls:
443452
return cls(pipeline_response, deserialized, {}) # type: ignore
@@ -486,7 +495,6 @@ def prepare_request(next_link=None):
486495
headers=_headers,
487496
params=_params,
488497
)
489-
_request = _convert_request(_request)
490498
_request.url = self._client.format_url(_request.url)
491499

492500
else:
@@ -502,7 +510,6 @@ def prepare_request(next_link=None):
502510
_request = HttpRequest(
503511
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
504512
)
505-
_request = _convert_request(_request)
506513
_request.url = self._client.format_url(_request.url)
507514
_request.method = "GET"
508515
return _request

0 commit comments

Comments
 (0)