Skip to content

Commit bddd553

Browse files
author
SDKAuto
committed
CodeGen from PR 31018 in Azure/azure-rest-api-specs
Merge 4fbfe4e7f116dd7b56b68ec93e125707f6a37d04 into 7a848fa439e779117793063aff964d7082a7f6f8
1 parent 005b1c3 commit bddd553

File tree

211 files changed

+10950
-2447
lines changed

Some content is hidden

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

211 files changed

+10950
-2447
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "edbae6fb086224abd5b744edc7b833fec0909617",
2+
"commit": "6871e43e9751993a8c11c9b209c9532ff34b3ab2",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.7",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.13.7",
6+
"@autorest/python@6.19.0",
77
"@autorest/[email protected]"
88
],
9-
"autorest_command": "autorest specification/eventgrid/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.7 --use=@autorest/[email protected] --version=3.9.7 --version-tolerant=False",
9+
"autorest_command": "autorest specification/eventgrid/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/eventgrid/resource-manager/readme.md"
1111
}

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_event_grid_management_client.py

Lines changed: 2 additions & 1 deletion
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
@@ -273,7 +274,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
273274
def close(self) -> None:
274275
self._client.close()
275276

276-
def __enter__(self) -> "EventGridManagementClient":
277+
def __enter__(self) -> Self:
277278
self._client.__enter__()
278279
return self
279280

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#
2626
# --------------------------------------------------------------------------
2727

28+
2829
# This file is used for handwritten extensions to the generated code. Example:
2930
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
3031
def patch_sdk():

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

Lines changed: 3 additions & 1 deletion
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
@@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data):
14411443
elif isinstance(response, type) and issubclass(response, Enum):
14421444
return self.deserialize_enum(data, response)
14431445

1444-
if data is None:
1446+
if data is None or data is CoreNull:
14451447
return data
14461448
try:
14471449
attributes = response._attribute_map # type: ignore

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

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

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_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 = "10.3.0b4"
9+
VERSION = "2.2.0"

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_event_grid_management_client.py

Lines changed: 2 additions & 1 deletion
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
@@ -278,7 +279,7 @@ def _send_request(
278279
async def close(self) -> None:
279280
await self._client.close()
280281

281-
async def __aenter__(self) -> "EventGridManagementClient":
282+
async def __aenter__(self) -> Self:
282283
await self._client.__aenter__()
283284
return self
284285

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#
2626
# --------------------------------------------------------------------------
2727

28+
2829
# This file is used for handwritten extensions to the generated code. Example:
2930
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
3031
def patch_sdk():

sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_ca_certificates_operations.py

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
99
from io import IOBase
10-
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
10+
import sys
11+
from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload
1112
import urllib.parse
1213

1314
from azure.core.async_paging import AsyncItemPaged, AsyncList
@@ -17,27 +18,31 @@
1718
ResourceExistsError,
1819
ResourceNotFoundError,
1920
ResourceNotModifiedError,
21+
StreamClosedError,
22+
StreamConsumedError,
2023
map_error,
2124
)
2225
from azure.core.pipeline import PipelineResponse
23-
from azure.core.pipeline.transport import AsyncHttpResponse
2426
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
25-
from azure.core.rest import HttpRequest
27+
from azure.core.rest import AsyncHttpResponse, HttpRequest
2628
from azure.core.tracing.decorator import distributed_trace
2729
from azure.core.tracing.decorator_async import distributed_trace_async
2830
from azure.core.utils import case_insensitive_dict
2931
from azure.mgmt.core.exceptions import ARMErrorFormat
3032
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
3133

3234
from ... import models as _models
33-
from ..._vendor import _convert_request
3435
from ...operations._ca_certificates_operations import (
3536
build_create_or_update_request,
3637
build_delete_request,
3738
build_get_request,
3839
build_list_by_namespace_request,
3940
)
4041

42+
if sys.version_info >= (3, 9):
43+
from collections.abc import MutableMapping
44+
else:
45+
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
4146
T = TypeVar("T")
4247
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
4348

@@ -80,7 +85,7 @@ async def get(
8085
:rtype: ~azure.mgmt.eventgrid.models.CaCertificate
8186
:raises ~azure.core.exceptions.HttpResponseError:
8287
"""
83-
error_map = {
88+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
8489
401: ClientAuthenticationError,
8590
404: ResourceNotFoundError,
8691
409: ResourceExistsError,
@@ -103,7 +108,6 @@ async def get(
103108
headers=_headers,
104109
params=_params,
105110
)
106-
_request = _convert_request(_request)
107111
_request.url = self._client.format_url(_request.url)
108112

109113
_stream = False
@@ -118,7 +122,7 @@ async def get(
118122
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
119123
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
120124

121-
deserialized = self._deserialize("CaCertificate", pipeline_response)
125+
deserialized = self._deserialize("CaCertificate", pipeline_response.http_response)
122126

123127
if cls:
124128
return cls(pipeline_response, deserialized, {}) # type: ignore
@@ -132,8 +136,8 @@ async def _create_or_update_initial(
132136
ca_certificate_name: str,
133137
ca_certificate_info: Union[_models.CaCertificate, IO[bytes]],
134138
**kwargs: Any
135-
) -> _models.CaCertificate:
136-
error_map = {
139+
) -> AsyncIterator[bytes]:
140+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
137141
401: ClientAuthenticationError,
138142
404: ResourceNotFoundError,
139143
409: ResourceExistsError,
@@ -146,7 +150,7 @@ async def _create_or_update_initial(
146150

147151
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
148152
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
149-
cls: ClsType[_models.CaCertificate] = kwargs.pop("cls", None)
153+
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)
150154

151155
content_type = content_type or "application/json"
152156
_json = None
@@ -168,26 +172,26 @@ async def _create_or_update_initial(
168172
headers=_headers,
169173
params=_params,
170174
)
171-
_request = _convert_request(_request)
172175
_request.url = self._client.format_url(_request.url)
173176

174-
_stream = False
177+
_decompress = kwargs.pop("decompress", True)
178+
_stream = True
175179
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
176180
_request, stream=_stream, **kwargs
177181
)
178182

179183
response = pipeline_response.http_response
180184

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

186-
if response.status_code == 200:
187-
deserialized = self._deserialize("CaCertificate", pipeline_response)
188-
189-
if response.status_code == 201:
190-
deserialized = self._deserialize("CaCertificate", pipeline_response)
194+
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)
191195

192196
if cls:
193197
return cls(pipeline_response, deserialized, {}) # type: ignore
@@ -310,10 +314,11 @@ async def begin_create_or_update(
310314
params=_params,
311315
**kwargs
312316
)
317+
await raw_result.http_response.read() # type: ignore
313318
kwargs.pop("error_map", None)
314319

315320
def get_long_running_output(pipeline_response):
316-
deserialized = self._deserialize("CaCertificate", pipeline_response)
321+
deserialized = self._deserialize("CaCertificate", pipeline_response.http_response)
317322
if cls:
318323
return cls(pipeline_response, deserialized, {}) # type: ignore
319324
return deserialized
@@ -338,10 +343,10 @@ def get_long_running_output(pipeline_response):
338343
self._client, raw_result, get_long_running_output, polling_method # type: ignore
339344
)
340345

341-
async def _delete_initial( # pylint: disable=inconsistent-return-statements
346+
async def _delete_initial(
342347
self, resource_group_name: str, namespace_name: str, ca_certificate_name: str, **kwargs: Any
343-
) -> None:
344-
error_map = {
348+
) -> AsyncIterator[bytes]:
349+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
345350
401: ClientAuthenticationError,
346351
404: ResourceNotFoundError,
347352
409: ResourceExistsError,
@@ -353,7 +358,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
353358
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
354359

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

358363
_request = build_delete_request(
359364
resource_group_name=resource_group_name,
@@ -364,17 +369,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements
364369
headers=_headers,
365370
params=_params,
366371
)
367-
_request = _convert_request(_request)
368372
_request.url = self._client.format_url(_request.url)
369373

370-
_stream = False
374+
_decompress = kwargs.pop("decompress", True)
375+
_stream = True
371376
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
372377
_request, stream=_stream, **kwargs
373378
)
374379

375380
response = pipeline_response.http_response
376381

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

395+
deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)
396+
386397
if cls:
387-
return cls(pipeline_response, None, response_headers) # type: ignore
398+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
399+
400+
return deserialized # type: ignore
388401

389402
@distributed_trace_async
390403
async def begin_delete(
@@ -414,7 +427,7 @@ async def begin_delete(
414427
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
415428
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
416429
if cont_token is None:
417-
raw_result = await self._delete_initial( # type: ignore
430+
raw_result = await self._delete_initial(
418431
resource_group_name=resource_group_name,
419432
namespace_name=namespace_name,
420433
ca_certificate_name=ca_certificate_name,
@@ -424,6 +437,7 @@ async def begin_delete(
424437
params=_params,
425438
**kwargs
426439
)
440+
await raw_result.http_response.read() # type: ignore
427441
kwargs.pop("error_map", None)
428442

429443
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
@@ -487,7 +501,7 @@ def list_by_namespace(
487501
api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
488502
cls: ClsType[_models.CaCertificatesListResult] = kwargs.pop("cls", None)
489503

490-
error_map = {
504+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
491505
401: ClientAuthenticationError,
492506
404: ResourceNotFoundError,
493507
409: ResourceExistsError,
@@ -508,7 +522,6 @@ def prepare_request(next_link=None):
508522
headers=_headers,
509523
params=_params,
510524
)
511-
_request = _convert_request(_request)
512525
_request.url = self._client.format_url(_request.url)
513526

514527
else:
@@ -524,7 +537,6 @@ def prepare_request(next_link=None):
524537
_request = HttpRequest(
525538
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
526539
)
527-
_request = _convert_request(_request)
528540
_request.url = self._client.format_url(_request.url)
529541
_request.method = "GET"
530542
return _request

0 commit comments

Comments
 (0)